Fixes ollama and updates openai dependency (#3452)

This commit is contained in:
Parshva Daftari
2025-09-12 01:39:39 +05:30
committed by GitHub
parent 21d69307dc
commit d48b1832c7
5 changed files with 36 additions and 10 deletions
+8
View File
@@ -91,6 +91,14 @@ class OllamaLLM(LLMBase):
"messages": messages,
}
# Handle JSON response format by modifying the system prompt
if response_format and response_format.get("type") == "json_object":
# Add JSON format instruction to the last message or create a system message
if messages and messages[-1]["role"] == "user":
messages[-1]["content"] += "\n\nPlease respond with valid JSON only."
else:
messages.append({"role": "user", "content": "Please respond with valid JSON only."})
# Add options for Ollama (temperature, num_predict, top_p)
options = {
"temperature": self.config.temperature,