Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
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 |
-
|
170 |
elif huggingface_model == "llama":
|
171 |
-
|
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 |
-
|
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 |
-
|
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
|