refactor(ollama): simplify options handling (#33199)

Fixes #32744

Don't restrict options; the client accepts any dict
This commit is contained in:
Mason Daugherty
2025-10-01 21:58:12 -04:00
committed by GitHub
parent a9eda18e1e
commit 6f2d16e6be

View File

@@ -42,7 +42,7 @@ from langchain_core.utils.function_calling import (
convert_to_openai_tool, convert_to_openai_tool,
) )
from langchain_core.utils.pydantic import TypeBaseModel, is_basemodel_subclass from langchain_core.utils.pydantic import TypeBaseModel, is_basemodel_subclass
from ollama import AsyncClient, Client, Message, Options from ollama import AsyncClient, Client, Message
from pydantic import BaseModel, PrivateAttr, model_validator from pydantic import BaseModel, PrivateAttr, model_validator
from pydantic.json_schema import JsonSchemaValue from pydantic.json_schema import JsonSchemaValue
from pydantic.v1 import BaseModel as BaseModelV1 from pydantic.v1 import BaseModel as BaseModelV1
@@ -675,7 +675,7 @@ class ChatOllama(BaseChatModel):
"model": kwargs.pop("model", self.model), "model": kwargs.pop("model", self.model),
"think": kwargs.pop("reasoning", self.reasoning), "think": kwargs.pop("reasoning", self.reasoning),
"format": kwargs.pop("format", self.format), "format": kwargs.pop("format", self.format),
"options": Options(**options_dict), "options": options_dict,
"keep_alive": kwargs.pop("keep_alive", self.keep_alive), "keep_alive": kwargs.pop("keep_alive", self.keep_alive),
**kwargs, **kwargs,
} }