wt002 commited on
Commit
2c06537
·
verified ·
1 Parent(s): ab6c455

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +6 -10
agent.py CHANGED
@@ -153,10 +153,9 @@ tools = [
153
 
154
  # Build graph function
155
  def build_graph(provider: str = "huggingface", huggingface_model: str = "mistral"):
156
- """Build the graph"""
157
 
158
  if provider == "google":
159
- # Google Gemini
160
  llm = ChatGoogleGenerativeAI(
161
  model="gemini-2.0-flash",
162
  temperature=0,
@@ -164,11 +163,10 @@ def build_graph(provider: str = "huggingface", huggingface_model: str = "mistral
164
  )
165
 
166
  elif provider == "huggingface":
167
- # Choose between supported Hugging Face models
168
  if huggingface_model == "mistral":
169
- model_url = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.1"
170
  elif huggingface_model == "llama":
171
- model_url = "https://api-inference.huggingface.co/models/Meta-DeepLearning/llama-2-7b-chat-hf"
172
  else:
173
  raise ValueError("Unsupported Hugging Face model")
174
 
@@ -177,7 +175,7 @@ def build_graph(provider: str = "huggingface", huggingface_model: str = "mistral
177
 
178
  llm = ChatHuggingFace(
179
  llm=HuggingFaceEndpoint(
180
- url=model_url,
181
  temperature=0,
182
  headers=headers
183
  )
@@ -186,10 +184,8 @@ def build_graph(provider: str = "huggingface", huggingface_model: str = "mistral
186
  else:
187
  raise ValueError("Invalid provider. Choose 'google' or 'huggingface'.")
188
 
189
- return llm
190
-
191
- # Bind tools to LLM
192
- llm_with_tools = llm.bind_tools(tools)
193
  return llm_with_tools
194
 
195
  # Node
 
153
 
154
  # Build graph function
155
  def build_graph(provider: str = "huggingface", huggingface_model: str = "mistral"):
156
+ """Build the graph with tool binding."""
157
 
158
  if provider == "google":
 
159
  llm = ChatGoogleGenerativeAI(
160
  model="gemini-2.0-flash",
161
  temperature=0,
 
163
  )
164
 
165
  elif provider == "huggingface":
 
166
  if huggingface_model == "mistral":
167
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.1"
168
  elif huggingface_model == "llama":
169
+ repo_id = "Meta-DeepLearning/llama-2-7b-chat-hf"
170
  else:
171
  raise ValueError("Unsupported Hugging Face model")
172
 
 
175
 
176
  llm = ChatHuggingFace(
177
  llm=HuggingFaceEndpoint(
178
+ repo_id=repo_id,
179
  temperature=0,
180
  headers=headers
181
  )
 
184
  else:
185
  raise ValueError("Invalid provider. Choose 'google' or 'huggingface'.")
186
 
187
+ # ✅ Bind tools if defined
188
+ llm_with_tools = llm.bind_tools(tools) # Make sure `tools` is defined/imported
 
 
189
  return llm_with_tools
190
 
191
  # Node