Commit
·
b478018
1
Parent(s):
3b91398
commit
Browse files- __pycache__/agent.cpython-310.pyc +0 -0
- agent.py +23 -20
__pycache__/agent.cpython-310.pyc
CHANGED
Binary files a/__pycache__/agent.cpython-310.pyc and b/__pycache__/agent.cpython-310.pyc differ
|
|
agent.py
CHANGED
@@ -157,27 +157,30 @@ if not hf_token:
|
|
157 |
# Build graph function
|
158 |
def build_graph(provider: str = "groq"):
|
159 |
"""Build the graph"""
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
huggingfacehub_api_token= hf_token
|
176 |
-
),
|
177 |
)
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
181 |
llm_with_tools = llm.bind_tools(tools)
|
182 |
|
183 |
# Node
|
|
|
157 |
# Build graph function
|
158 |
def build_graph(provider: str = "groq"):
|
159 |
"""Build the graph"""
|
160 |
+
|
161 |
+
repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
162 |
+
|
163 |
+
if not hf_token:
|
164 |
+
raise ValueError("HF_TOKEN environment variable not set. It's required for Hugging Face provider.")
|
165 |
+
|
166 |
+
try:
|
167 |
+
# Initialize the HuggingFaceEndpoint
|
168 |
+
endpoint_llm = HuggingFaceEndpoint(
|
169 |
+
repo_id=repo_id,
|
170 |
+
temperature=0,
|
171 |
+
huggingfacehub_api_token=hf_token,
|
172 |
+
# You might want to add other parameters like:
|
173 |
+
# max_new_tokens=512,
|
174 |
+
# model_kwargs={"top_k": 10}
|
|
|
|
|
175 |
)
|
176 |
+
# Wrap it with ChatHuggingFace for a chat interface
|
177 |
+
llm = ChatHuggingFace(llm=endpoint_llm)
|
178 |
+
print(f"Successfully initialized Hugging Face LLM: {repo_id}")
|
179 |
+
|
180 |
+
except Exception as e:
|
181 |
+
# This error is specific to Hugging Face LLM instantiation failing
|
182 |
+
raise RuntimeError(f"Failed to initialize Hugging Face model ('{repo_id}'): {e}") from e
|
183 |
+
|
184 |
llm_with_tools = llm.bind_tools(tools)
|
185 |
|
186 |
# Node
|