fix/refac: use ollama /api/chat endpoint for tasks

This commit is contained in:
Timothy J. Baek
2024-09-21 00:30:13 +02:00
parent 585b9eb84a
commit 41926172d3
3 changed files with 111 additions and 21 deletions

View File

@@ -0,0 +1,14 @@
from open_webui.utils.task import prompt_template
from open_webui.utils.misc import (
openai_chat_completion_message_template,
)
from typing import Callable, Optional
def convert_response_ollama_to_openai(ollama_response: dict) -> dict:
model = ollama_response.get("model", "ollama")
message_content = ollama_response.get("message", {}).get("content", "")
response = openai_chat_completion_message_template(model, message_content)
return response