RohitKeswani commited on
Commit
4366345
·
1 Parent(s): ce7067d

adding chat model

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -2,11 +2,21 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  from langgraph.prebuilt import create_react_agent
4
  from search_agent import tools
 
5
  """
6
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
7
  """
8
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
- graph = create_react_agent(client, tools=tools)
 
 
 
 
 
 
 
 
 
10
 
11
 
12
  def respond(
 
2
  from huggingface_hub import InferenceClient
3
  from langgraph.prebuilt import create_react_agent
4
  from search_agent import tools
5
+ from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
6
  """
7
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
8
  """
9
+ # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
+ llm = HuggingFaceEndpoint(
11
+ repo_id="HuggingFaceH4/zephyr-7b-beta",
12
+ task="text-generation",
13
+ max_new_tokens=512,
14
+ do_sample=False,
15
+ repetition_penalty=1.03,
16
+ )
17
+
18
+ chat_model = ChatHuggingFace(llm=llm)
19
+ graph = create_react_agent(chat_model, tools=tools)
20
 
21
 
22
  def respond(