The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]:sparkllm standardize init args (#20194)
Guangdong Liu4be7ca7b4c38
diff --git a/libs/community/langchain_community/chat_models/sparkllm.py b/libs/community/langchain_community/chat_models/sparkllm.pyindex e3b36bed9b..f173519746 100644--- a/libs/community/langchain_community/chat_models/sparkllm.py+++ b/libs/community/langchain_community/chat_models/sparkllm.py@@ -141,11 +141,16 @@ class ChatSparkLLM(BaseChatModel):spark_llm_domain: Optional[str] = Nonespark_user_id: str = "lc_user"streaming: bool = False- request_timeout: int = 30+ request_timeout: int = Field(30, alias="timeout")temperature: float = 0.5top_k: int = 4model_kwargs: Dict[str, Any] = Field(default_factory=dict)+ class Config:+ """Configuration for this pydantic object."""++ allow_population_by_field_name = True+@root_validator(pre=True)def build_extra(cls, values: Dict[str, Any]) -> Dict[str, Any]:"""Build extra kwargs from additional params that were passed in."""diff --git a/libs/community/tests/integration_tests/chat_models/test_sparkllm.py b/libs/community/tests/integration_tests/chat_models/test_sparkllm.pyindex fcb3a7a7f9..65fc38712c 100644--- a/libs/community/tests/integration_tests/chat_models/test_sparkllm.py+++ b/libs/community/tests/integration_tests/chat_models/test_sparkllm.py@@ -3,6 +3,15 @@ from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessagefrom langchain_community.chat_models.sparkllm import ChatSparkLLM+def test_initialization() -> None:+ """Test chat model initialization."""+ for model in [+ ChatSparkLLM(timeout=30),+ ChatSparkLLM(request_timeout=30),+ ]:+ assert model.request_timeout == 30++def test_chat_spark_llm() -> None:chat = ChatSparkLLM()message = HumanMessage(content="Hello")