mnab commited on
Commit
51d956c
·
verified ·
1 Parent(s): f000e59

Upload agent.py

Browse files
Files changed (1) hide show
  1. agent.py +29 -23
agent.py CHANGED
@@ -209,18 +209,18 @@ search_tool = DuckDuckGoSearchResults()
209
  # temperature=0.2,
210
  # max_tokens=4096,
211
  # )
212
- # llm = ChatHuggingFace(
213
- # llm=HuggingFaceEndpoint(
214
- # # repo_id="microsoft/Phi-3-mini-4k-instruct",
215
- # repo_id="meta-llama/Llama-3-70B-Instruct",
216
- # temperature=0,
217
- # # huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
218
- # ),
219
- # verbose=True,
220
- # )
221
- llm = ChatGoogleGenerativeAI(
222
- model="gemini-2.0-flash-exp", google_api_key=os.environ["GOOGLE_API_KEY"]
223
  )
 
 
 
224
  tools = [
225
  analyze_csv_file,
226
  analyze_excel_file,
@@ -274,10 +274,16 @@ def build_agent_workflow():
274
  """
275
 
276
  if question.startswith(".") or ".rewsna eht sa" in question:
 
 
 
277
  context = f"""
278
- This question appears to be in reversed text. Here's the reversed version:
279
- {state['message'][::-1]}
280
- Now answer the question above. Remember to format your answer exactly as requested.
 
 
 
281
  """
282
  system_prompt = SystemMessage(
283
  f"""{context}
@@ -304,12 +310,12 @@ def build_agent_workflow():
304
  return app
305
 
306
 
307
- # if __name__ == "__main__":
308
- # question = "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?"
309
- # # Build the graph
310
- # graph = build_agent_workflow()
311
- # # Run the graph
312
- # messages = [HumanMessage(content=question)]
313
- # messages = graph.invoke({"messages": messages, "input_file": None})
314
- # for m in messages["messages"]:
315
- # m.pretty_print()
 
209
  # temperature=0.2,
210
  # max_tokens=4096,
211
  # )
212
+ llm = ChatHuggingFace(
213
+ llm=HuggingFaceEndpoint(
214
+ repo_id="Qwen/Qwen3-30B-A3B",
215
+ # repo_id="meta-llama/Llama-3-70B-Instruct",
216
+ temperature=0,
217
+ huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
218
+ ),
219
+ verbose=True,
 
 
 
220
  )
221
+ # llm = ChatGoogleGenerativeAI(
222
+ # model="gemini-2.0-flash-exp", google_api_key=os.environ["GOOGLE_API_KEY"]
223
+ # )
224
  tools = [
225
  analyze_csv_file,
226
  analyze_excel_file,
 
274
  """
275
 
276
  if question.startswith(".") or ".rewsna eht sa" in question:
277
+ print("Reversed text detected.")
278
+ print(state.get("messages")[::-1])
279
+
280
  context = f"""
281
+ This question appears to be in reversed text. your task to reverse the sentence. Here's the reversed example:
282
+ .rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI
283
+ and the answer is:
284
+ "If you understand this sentence, write the opposite of the word "left" as the answer."
285
+
286
+ Now rewrite in to proper formate the {question}. Remember to format your answer exactly as requested.
287
  """
288
  system_prompt = SystemMessage(
289
  f"""{context}
 
310
  return app
311
 
312
 
313
+ if __name__ == "__main__":
314
+ question = '.rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI'
315
+ # Build the graph
316
+ graph = build_agent_workflow()
317
+ # Run the graph
318
+ messages = [HumanMessage(content=question)]
319
+ messages = graph.invoke({"messages": messages, "input_file": None})
320
+ for m in messages["messages"]:
321
+ m.pretty_print()