-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathnodes.py
More file actions
34 lines (26 loc) · 955 Bytes
/
nodes.py
File metadata and controls
34 lines (26 loc) · 955 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
32
33
34
from langgraph.prebuilt.tool_node import ToolNode
from langgraph.runtime import Runtime
from examples.ex010.context import Context
from examples.ex010.state import State
from examples.ex010.tools import TOOLS
from examples.ex010.utils import load_llm
tool_node = ToolNode(tools=TOOLS)
def call_llm(state: State, runtime: Runtime[Context]) -> State:
print("> call llm")
ctx = runtime.context
user_type = ctx.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]}