fix: missing parenthesis

This commit is contained in:
LUIS NOVO 2025-10-18 13:22:39 -03:00
parent 8b5daa86bc
commit a51bb9d792

View file

@ -26,9 +26,8 @@ class ThreadState(TypedDict):
def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict: def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict:
system_prompt = Prompter(prompt_template="chat").render(data=state) # type: ignore[arg-type] system_prompt = Prompter(prompt_template="chat").render(data=state) # type: ignore[arg-type]
payload = [SystemMessage(content=system_prompt)] + state.get("messages", []) payload = [SystemMessage(content=system_prompt)] + state.get("messages", [])
model_id = ( model_id = config.get("configurable", {}).get("model_id") or state.get(
config.get("configurable", {}).get("model_id") "model_override"
or state.get("model_override")
) )
# Handle async model provisioning from sync context # Handle async model provisioning from sync context
@ -39,10 +38,8 @@ def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict
asyncio.set_event_loop(new_loop) asyncio.set_event_loop(new_loop)
return new_loop.run_until_complete( return new_loop.run_until_complete(
provision_langchain_model( provision_langchain_model(
str(payload), str(payload), model_id, "chat", max_tokens=8192
model_id, )
"chat",
max_tokens=8192
) )
finally: finally:
new_loop.close() new_loop.close()
@ -53,6 +50,7 @@ def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict
asyncio.get_running_loop() asyncio.get_running_loop()
# If we're in an event loop, run in a thread with a new loop # If we're in an event loop, run in a thread with a new loop
import concurrent.futures import concurrent.futures
with concurrent.futures.ThreadPoolExecutor() as executor: with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(run_in_new_loop) future = executor.submit(run_in_new_loop)
model = future.result() model = future.result()