BoddyGus commited on
Commit
c74b856
·
verified ·
1 Parent(s): 9f2aecf

Changing ChatOllama with ChatHuggingFace

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -13,7 +13,7 @@ from langgraph.prebuilt import ToolNode, tools_condition
13
  from langchain_core.messages import AnyMessage, HumanMessage, AIMessage
14
  from typing import TypedDict, Annotated
15
  from langgraph.graph.message import add_messages
16
- from langchain_ollama.chat_models import ChatOllama
17
 
18
  # (Keep Constants as is)
19
  # --- Constants ---
@@ -22,6 +22,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
22
  # --- Basic Agent Definition ---
23
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
24
 
 
25
  class BasicAgent:
26
  def __init__(self):
27
  print("BasicAgent initialized.")
@@ -30,7 +31,13 @@ class BasicAgent:
30
  search_tool = DuckDuckGoSearchRun()
31
  tools = [search_tool]
32
 
33
- chat = ChatOllama(model="qwen2.5-coder:7b", temperature=0, base_url="http://localhost:11434")
 
 
 
 
 
 
34
  chat_with_tools = chat.bind_tools(tools)
35
 
36
  class AgentState(TypedDict):
 
13
  from langchain_core.messages import AnyMessage, HumanMessage, AIMessage
14
  from typing import TypedDict, Annotated
15
  from langgraph.graph.message import add_messages
16
+ from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
17
 
18
  # (Keep Constants as is)
19
  # --- Constants ---
 
22
  # --- Basic Agent Definition ---
23
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
24
 
25
+
26
  class BasicAgent:
27
  def __init__(self):
28
  print("BasicAgent initialized.")
 
31
  search_tool = DuckDuckGoSearchRun()
32
  tools = [search_tool]
33
 
34
+ llm = HuggingFaceEndpoint(
35
+ repo_id="Qwen/Qwen2.5-Coder-32B-Instruct",
36
+ huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN,
37
+ )
38
+
39
+ chat = ChatHuggingFace(llm=llm, verbose=True)
40
+ tools = [search_tool, weather_info_tool, hub_stats_tool]
41
  chat_with_tools = chat.bind_tools(tools)
42
 
43
  class AgentState(TypedDict):