Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: stop OpenAI chats failing on earlier replies sent as parts (#16945)
Nilay25d4692c3b83
diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.pyindex f22be214eb7..586bcd973fe 100644--- a/studio/backend/core/inference/external_provider.py+++ b/studio/backend/core/inference/external_provider.py@@ -5668,14 +5668,10 @@ class ExternalProviderClient:if _pt == "text" and _part.get("text"):_asst_parts.append({- "type": "input_text",+ "type": "output_text","text": _part.get("text", ""),})- elif _pt == "image_url":- _u = _part.get("image_url", {}).get("url", "")- if _u:- _asst_parts.append({"type": "input_image", "image_url": _u})if _asst_parts:_turn_items.append({"role": "assistant", "content": _asst_parts})@@ -5741,9 +5737,12 @@ class ExternalProviderClient:part_type = part.get("type")if part_type == "text":translated_parts.append(- {"type": "input_text", "text": part.get("text", "")}+ {+ "type": "output_text" if role == "assistant" else "input_text",+ "text": part.get("text", ""),+ })- elif part_type == "image_url":+ elif part_type == "image_url" and role != "assistant":url = part.get("image_url", {}).get("url", "")if url:# Responses takes image_url as a flat string (https:// and data: URLs both accepted).diff --git a/studio/backend/tests/test_openai_responses_translation.py b/studio/backend/tests/test_openai_responses_translation.pyindex fed64396cf9..fabdf8da8e0 100644--- a/studio/backend/tests/test_openai_responses_translation.py+++ b/studio/backend/tests/test_openai_responses_translation.py@@ -265,6 +265,60 @@ def test_responses_translates_image_parts(monkeypatch):assert "max_output_tokens" not in captured["body"]+def test_responses_assistant_list_content_is_sent_as_output_text(monkeypatch):+ captured: dict = {}++ def handler(request: httpx.Request) -> httpx.Response:+ captured["body"] = json.loads(request.content.decode("utf-8"))+ return httpx.Response(+ 200,+ content = _responses_sse([{"type": "response.completed", "response": {}}]),+ headers = {"content-type": "text/event-stream"},+ )++ _mock_http_client(monkeypatch, handler)+ image = {"type": "image_url", "image_url": {"url": "data:image/png;base64,AAA"}}++ async def run():+ client = _make_client()+ async for _ in client._stream_openai_responses(+ messages = [+ {"role": "user", "content": "Pick a colour."},+ {"role": "assistant", "content": [{"type": "text", "text": "Blue."}, image]},+ {"role": "user", "content": "Check the weather."},+ {+ "role": "assistant",+ "content": [{"type": "text", "text": "Looking it up."}, image],+ "tool_calls": [+ {+ "id": "call_1",+ "type": "function",+ "function": {"name": "get_weather", "arguments": "{}"},+ }+ ],+ },+ {"role": "tool", "tool_call_id": "call_1", "content": "Sunny"},+ {"role": "user", "content": "Thanks."},+ ],+ model = "gpt-5.5",+ temperature = 0.7,+ top_p = 0.95,+ max_tokens = None,+ enable_thinking = None,+ reasoning_effort = None,+ ):+ pass+ await client.close()++ _drive(run())++ assistant_items = [i for i in captured["body"]["input"] if i.get("role") == "assistant"]+ assert [i["content"] for i in assistant_items] == [+ [{"type": "output_text", "text": "Blue."}],+ [{"type": "output_text", "text": "Looking it up."}],+ ]++def test_responses_sse_translates_to_chat_completions_chunks(monkeypatch):def handler(request: httpx.Request) -> httpx.Response:events = [