From 44711fe018d462fc2adbc9d2dc301cc6cb9819c3 Mon Sep 17 00:00:00 2001 From: giwaov Date: Wed, 8 Apr 2026 10:51:32 +0100 Subject: [PATCH] fix: use LLM.from_url() when llm_server_url is provided OpenGradientChatModel passed llm_server_url as a kwarg to LLM(), but LLM.__init__() does not accept that parameter, causing a TypeError at runtime. The correct API is LLM.from_url(). When llm_server_url is provided, call LLM.from_url(private_key, llm_server_url) instead of LLM(private_key, **llm_kwargs). Closes #248 --- src/opengradient/agents/og_langchain.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/opengradient/agents/og_langchain.py b/src/opengradient/agents/og_langchain.py index cc3ce16..f1b5a60 100644 --- a/src/opengradient/agents/og_langchain.py +++ b/src/opengradient/agents/og_langchain.py @@ -177,15 +177,16 @@ def __init__( if not private_key: raise ValueError("private_key is required when client is not provided.") - llm_kwargs: Dict[str, Any] = {} - if rpc_url is not None: - llm_kwargs["rpc_url"] = rpc_url - if tee_registry_address is not None: - llm_kwargs["tee_registry_address"] = tee_registry_address if llm_server_url is not None: - llm_kwargs["llm_server_url"] = llm_server_url + self._llm = LLM.from_url(private_key, llm_server_url) + else: + llm_kwargs: Dict[str, Any] = {} + if rpc_url is not None: + llm_kwargs["rpc_url"] = rpc_url + if tee_registry_address is not None: + llm_kwargs["tee_registry_address"] = tee_registry_address - self._llm = LLM(private_key=private_key, **llm_kwargs) + self._llm = LLM(private_key=private_key, **llm_kwargs) self._owns_client = True @property