-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathnodes.py
More file actions
31 lines (24 loc) · 927 Bytes
/
Copy pathnodes.py
File metadata and controls
31 lines (24 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from langgraph.graph.state import RunnableConfig
from langgraph.prebuilt.tool_node import ToolNode
from examples.ex008.state import State
from examples.ex008.tools import TOOLS
from examples.ex008.utils import load_llm
tool_node = ToolNode(tools=TOOLS)
def call_llm(state: State, config: RunnableConfig) -> State:
print("> call llm")
user_type = config.get("configurable", {}).get("user_type")
model_provider = "ollama" if user_type == "plus" else "ollama" # noqa: RUF034
model = "gpt-oss:20b" if user_type == "plus" else "qwen3-coder:30b"
llm_with_tools = load_llm().bind_tools(TOOLS)
llm_with_config = llm_with_tools.with_config(
config={
"configurable": {
"model": model,
"model_provider": model_provider,
}
}
)
result = llm_with_config.invoke(
state["messages"],
)
return {"messages": [result]}