From 23a3abb294f214aeae950f34b1149f2877ebafd4 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Tue, 23 Jan 2024 12:36:35 -0500 Subject: [PATCH] Ollama part2 (#356) Co-authored-by: Tedfulk --- instructor/patch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instructor/patch.py b/instructor/patch.py index 968c0ed..7f2cb72 100644 --- a/instructor/patch.py +++ b/instructor/patch.py @@ -51,10 +51,10 @@ def dump_message(message: ChatCompletionMessage) -> ChatCompletionMessageParam: "role": message.role, "content": message.content or "", } - if message.tool_calls is not None: + if hasattr(message, "tool_calls") and message.tool_calls is not None: ret["tool_calls"] = message.model_dump()["tool_calls"] ret["content"] += json.dumps(message.model_dump()["tool_calls"]) - if message.function_call is not None: + if hasattr(message, "function_call") and message.function_call is not None: ret["content"] += json.dumps(message.model_dump()["function_call"]) return ret