Spaces:
Sleeping
Sleeping
Upload agent.py
Browse files
agent.py
CHANGED
@@ -209,18 +209,18 @@ search_tool = DuckDuckGoSearchResults()
|
|
209 |
# temperature=0.2,
|
210 |
# max_tokens=4096,
|
211 |
# )
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
#
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
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
|
279 |
-
|
280 |
-
|
|
|
|
|
|
|
281 |
"""
|
282 |
system_prompt = SystemMessage(
|
283 |
f"""{context}
|
@@ -304,12 +310,12 @@ def build_agent_workflow():
|
|
304 |
return app
|
305 |
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
#
|
310 |
-
|
311 |
-
#
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
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()
|