Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ import unicodedata
|
|
| 10 |
from typing import TypedDict, Annotated
|
| 11 |
|
| 12 |
from langchain_core.messages import AnyMessage, HumanMessage, SystemMessage
|
| 13 |
-
from
|
| 14 |
from langchain_core.tools import tool
|
| 15 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 16 |
from langchain_community.utilities import WikipediaAPIWrapper
|
|
@@ -134,13 +134,14 @@ class BasicAgent:
|
|
| 134 |
|
| 135 |
# Pattern esatto dal notebook del corso:
|
| 136 |
# llm.bind_tools() + StateGraph costruito manualmente
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
temperature=0.1,
|
| 142 |
-
max_tokens=1024,
|
| 143 |
)
|
|
|
|
| 144 |
self.llm_with_tools = llm.bind_tools(tools, parallel_tool_calls=False)
|
| 145 |
|
| 146 |
# Grafo ReAct: assistant → tools → assistant (loop)
|
|
|
|
| 10 |
from typing import TypedDict, Annotated
|
| 11 |
|
| 12 |
from langchain_core.messages import AnyMessage, HumanMessage, SystemMessage
|
| 13 |
+
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
|
| 14 |
from langchain_core.tools import tool
|
| 15 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 16 |
from langchain_community.utilities import WikipediaAPIWrapper
|
|
|
|
| 134 |
|
| 135 |
# Pattern esatto dal notebook del corso:
|
| 136 |
# llm.bind_tools() + StateGraph costruito manualmente
|
| 137 |
+
endpoint = HuggingFaceEndpoint(
|
| 138 |
+
repo_id="Qwen/Qwen2.5-72B-Instruct", # tool calling nativo
|
| 139 |
+
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 140 |
+
task="conversational",
|
| 141 |
+
max_new_tokens=1024,
|
| 142 |
temperature=0.1,
|
|
|
|
| 143 |
)
|
| 144 |
+
llm = ChatHuggingFace(llm=endpoint, verbose=False)
|
| 145 |
self.llm_with_tools = llm.bind_tools(tools, parallel_tool_calls=False)
|
| 146 |
|
| 147 |
# Grafo ReAct: assistant → tools → assistant (loop)
|