Merge branch 'ollama_no_stream' into '0.4.0'

Fix ollama models

See merge request aliasrobotics/alias_research/cai!205
This commit is contained in:
Luis Javier Navarrete Lozano 2025-05-26 14:28:50 +00:00
commit d9abd4636c
1 changed files with 2 additions and 6 deletions

View File

@ -2548,7 +2548,6 @@ class OpenAIChatCompletionsModel(Model):
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven,
stream: bool,
parallel_tool_calls: bool,
provider="ollama"
) -> ChatCompletion | tuple[Response, AsyncStream[ChatCompletionChunk]]:
"""
Fetches a response from an Ollama or Qwen model using LiteLLM, ensuring
@ -2561,7 +2560,6 @@ class OpenAIChatCompletionsModel(Model):
tool_choice (ChatCompletionToolChoiceOptionParam | NotGiven): Tool choice.
stream (bool): Whether to stream the response.
parallel_tool_calls (bool): Whether to allow parallel tool calls.
provider (str): Provider name, defaults to "ollama".
Returns:
ChatCompletion or tuple[Response, AsyncStream[ChatCompletionChunk]]:
@ -2601,8 +2599,6 @@ class OpenAIChatCompletionsModel(Model):
model_str = str(self.model).lower()
is_qwen = "qwen" in model_str
api_base = get_ollama_api_base()
if "ollama" in provider:
api_base = api_base.rstrip('/v1')
if stream:
response = Response(
@ -2623,7 +2619,7 @@ class OpenAIChatCompletionsModel(Model):
stream_obj = await litellm.acompletion(
**ollama_kwargs,
api_base=api_base,
custom_llm_provider=provider,
custom_llm_provider="openai"
)
return response, stream_obj
else:
@ -2631,7 +2627,7 @@ class OpenAIChatCompletionsModel(Model):
return litellm.completion(
**ollama_kwargs,
api_base=api_base,
custom_llm_provider=provider,
custom_llm_provider="openai",
)
def _intermediate_logs(self):