Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -9,6 +9,7 @@ from langgraph.graph.message import add_messages
|
|
| 9 |
from langchain_groq import ChatGroq
|
| 10 |
from langgraph.graph import StateGraph, START, END
|
| 11 |
from langgraph.prebuilt import ToolNode, tools_condition
|
|
|
|
| 12 |
|
| 13 |
@tool
|
| 14 |
def read_file(directory:str)->str:
|
|
@@ -130,8 +131,10 @@ tools = [read_file, wikipedia_fetcher, web_search, add, subtract, divide, multip
|
|
| 130 |
class AgentState(TypedDict):
|
| 131 |
messages: Annotated[List[AnyMessage], add_messages]
|
| 132 |
|
|
|
|
|
|
|
| 133 |
def call_model(state: AgentState):
|
| 134 |
-
llm = ChatGroq(model="qwen/qwen3-32b", temperature=0, api_key=
|
| 135 |
llm_with_tools = llm.bind_tools(tools)
|
| 136 |
response = llm_with_tools.invoke(state['messages'])
|
| 137 |
return {'messages': [response]}
|
|
|
|
| 9 |
from langchain_groq import ChatGroq
|
| 10 |
from langgraph.graph import StateGraph, START, END
|
| 11 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 12 |
+
import os
|
| 13 |
|
| 14 |
@tool
|
| 15 |
def read_file(directory:str)->str:
|
|
|
|
| 131 |
class AgentState(TypedDict):
|
| 132 |
messages: Annotated[List[AnyMessage], add_messages]
|
| 133 |
|
| 134 |
+
api_key = os.getenv('GROQ_API_KEY')
|
| 135 |
+
|
| 136 |
def call_model(state: AgentState):
|
| 137 |
+
llm = ChatGroq(model="qwen/qwen3-32b", temperature=0, api_key=api_key)
|
| 138 |
llm_with_tools = llm.bind_tools(tools)
|
| 139 |
response = llm_with_tools.invoke(state['messages'])
|
| 140 |
return {'messages': [response]}
|