diff --git a/backend/open_webui/routers/ollama.py b/backend/open_webui/routers/ollama.py index 233e30ce5..0c152c1f0 100644 --- a/backend/open_webui/routers/ollama.py +++ b/backend/open_webui/routers/ollama.py @@ -917,7 +917,7 @@ class ChatMessage(BaseModel): class GenerateChatCompletionForm(BaseModel): model: str messages: list[ChatMessage] - format: Optional[str] = None + format: Optional[dict] = None options: Optional[dict] = None template: Optional[str] = None stream: Optional[bool] = True diff --git a/backend/open_webui/utils/payload.py b/backend/open_webui/utils/payload.py index 04e3a98c4..0125a799c 100644 --- a/backend/open_webui/utils/payload.py +++ b/backend/open_webui/utils/payload.py @@ -154,6 +154,9 @@ def convert_payload_openai_to_ollama(openai_payload: dict) -> dict: ) ollama_payload["stream"] = openai_payload.get("stream", False) + if "format" in openai_payload: + ollama_payload["format"] = openai_payload["format"] + # If there are advanced parameters in the payload, format them in Ollama's options field ollama_options = {}