From 5b77f3839b515ecb09e7f30de10c3b679a38a2d8 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 14 Apr 2025 20:24:05 +0100 Subject: [PATCH] fix: maybe --- application/llm/openai.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/application/llm/openai.py b/application/llm/openai.py index ad0a0d56..75bd37e0 100644 --- a/application/llm/openai.py +++ b/application/llm/openai.py @@ -39,15 +39,6 @@ class OpenAILLM(BaseLLM): cleaned_messages.append( {"role": role, "content": item["text"]} ) - elif isinstance(item, dict): - content_parts = [] - if "text" in item: - content_parts.append({"type": "text", "text": item["text"]}) - elif "type" in item and item["type"] == "text" and "text" in item: - content_parts.append(item) - elif "type" in item and item["type"] == "file" and "file" in item: - content_parts.append(item) - cleaned_messages.append({"role": role, "content": content_parts}) elif "function_call" in item: tool_call = { "id": item["function_call"]["call_id"], @@ -78,6 +69,15 @@ class OpenAILLM(BaseLLM): ), } ) + elif isinstance(item, dict): + content_parts = [] + if "text" in item: + content_parts.append({"type": "text", "text": item["text"]}) + elif "type" in item and item["type"] == "text" and "text" in item: + content_parts.append(item) + elif "type" in item and item["type"] == "file" and "file" in item: + content_parts.append(item) + cleaned_messages.append({"role": role, "content": content_parts}) else: raise ValueError( f"Unexpected content dictionary format: {item}"