Fixes ollama and updates openai dependency (#3452)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user