jarguello76 commited on
Commit
a7f71dd
·
verified ·
1 Parent(s): c4e10ac

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +19 -9
tools.py CHANGED
@@ -136,17 +136,27 @@ def build_graph(csv_file_path: str = "embeddings.csv"):
136
 
137
  import os
138
 
139
- from langchain_huggingface import HuggingFaceEndpoint
140
-
141
- from langchain_community.chat_models import ChatHuggingFace
142
 
143
- llm = ChatHuggingFace(
144
- repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
145
- huggingfacehub_api_token=os.environ["agents_token"],
146
- max_new_tokens=512,
147
- temperature=0.7,
 
 
 
 
 
 
148
  )
149
- llm_with_tools = llm.bind_tools(tools=tools)
 
 
 
 
150
 
151
 
152
 
 
136
 
137
  import os
138
 
139
+ from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline
140
+ import getpass
141
+ import os
142
 
143
+ os.environ["agents_token"] = getpass.getpass(
144
+ "Enter your Hugging Face API key: "
145
+ )
146
+ llm = HuggingFacePipeline.from_model_id(
147
+ model_id="meta-llama/Meta-Llama-3-8B-Instruct",
148
+ task="text-generation",
149
+ pipeline_kwargs=dict(
150
+ max_new_tokens=512,
151
+ do_sample=False,
152
+ repetition_penalty=1.03,
153
+ ),
154
  )
155
+
156
+ chat_model = ChatHuggingFace(llm=llm)
157
+
158
+
159
+ llm_with_tools = chat_model.bind_tools(tools=tools)
160
 
161
 
162