This commit is contained in:
Timothy Jaeryang Baek
2026-04-14 16:47:43 -05:00
parent a4ed16999e
commit 8bd23b9145
2 changed files with 7 additions and 0 deletions
+2
View File
@@ -1020,6 +1020,8 @@ class ChatMessage(BaseModel):
tool_calls: Optional[list[dict]] = None
images: Optional[list[str]] = None
model_config = ConfigDict(extra='allow')
@validator('content', pre=True)
@classmethod
def check_at_least_one_field(cls, field_value, values, **kwargs):
+5
View File
@@ -204,6 +204,11 @@ def convert_messages_openai_to_ollama(messages: list[dict]) -> list[dict]:
# Initialize the new message structure with the role
new_message = {'role': message['role']}
# Preserve Ollama-native 'thinking' field (used by reasoning models,
# may be injected by filter inlet functions).
if 'thinking' in message:
new_message['thinking'] = message['thinking']
content = message.get('content', [])
tool_calls = message.get('tool_calls', None)
tool_call_id = message.get('tool_call_id', None)