Update app.py
Browse files
app.py
CHANGED
|
@@ -865,16 +865,16 @@ def tool_executor(state: AgentState):
|
|
| 865 |
"extremely",]
|
| 866 |
webpage_information_complete = " \n ".join(texts)
|
| 867 |
else:
|
| 868 |
-
webpage_results = visit_webpage_wiki(
|
| 869 |
webpage_result = " \n ".join(webpage_results)
|
| 870 |
-
|
| 871 |
# for webpage_result in webpage_results:
|
| 872 |
query_embeddings = sentence_transformer_model.encode_query(state["messages"][-1].content).reshape(1, -1)
|
| 873 |
webpage_information_embeddings = sentence_transformer_model.encode_query(webpage_result).reshape(1, -1)
|
| 874 |
query_webpage_information_similarity_score = float(cosine_similarity(query_embeddings, webpage_information_embeddings)[0][0])
|
| 875 |
|
| 876 |
# logger.info(f"Webpage Information and Similarity Score: {result} - {webpage_result} - {query_webpage_information_similarity_score}")
|
| 877 |
-
|
| 878 |
if query_webpage_information_similarity_score > 0.65:
|
| 879 |
webpage_information_complete += webpage_result
|
| 880 |
webpage_information_complete += " \n "
|
|
@@ -907,8 +907,10 @@ def tool_executor(state: AgentState):
|
|
| 907 |
except Exception as e:
|
| 908 |
webpage_information_complete = str(e)
|
| 909 |
pass
|
|
|
|
|
|
|
| 910 |
else:
|
| 911 |
-
|
| 912 |
|
| 913 |
if webpage_information_complete == "" and best_query_webpage_information_similarity_score > 0.30:
|
| 914 |
webpage_information_complete = best_webpage_information
|
|
@@ -1016,6 +1018,9 @@ class BasicAgent:
|
|
| 1016 |
response = self.safe_app.invoke(state)
|
| 1017 |
agent_answer = response["output"]
|
| 1018 |
|
|
|
|
|
|
|
|
|
|
| 1019 |
agent_answer = str(response)
|
| 1020 |
|
| 1021 |
# agent_answer = str(df)
|
|
|
|
| 865 |
"extremely",]
|
| 866 |
webpage_information_complete = " \n ".join(texts)
|
| 867 |
else:
|
| 868 |
+
webpage_results = visit_webpage_wiki(action["args"]["url"])
|
| 869 |
webpage_result = " \n ".join(webpage_results)
|
| 870 |
+
|
| 871 |
# for webpage_result in webpage_results:
|
| 872 |
query_embeddings = sentence_transformer_model.encode_query(state["messages"][-1].content).reshape(1, -1)
|
| 873 |
webpage_information_embeddings = sentence_transformer_model.encode_query(webpage_result).reshape(1, -1)
|
| 874 |
query_webpage_information_similarity_score = float(cosine_similarity(query_embeddings, webpage_information_embeddings)[0][0])
|
| 875 |
|
| 876 |
# logger.info(f"Webpage Information and Similarity Score: {result} - {webpage_result} - {query_webpage_information_similarity_score}")
|
| 877 |
+
|
| 878 |
if query_webpage_information_similarity_score > 0.65:
|
| 879 |
webpage_information_complete += webpage_result
|
| 880 |
webpage_information_complete += " \n "
|
|
|
|
| 907 |
except Exception as e:
|
| 908 |
webpage_information_complete = str(e)
|
| 909 |
pass
|
| 910 |
+
elif "answer" in state["proposed_action"]:
|
| 911 |
+
webpage_information_complete = f"""answer: {state["proposed_action"]["answer"]}"""
|
| 912 |
else:
|
| 913 |
+
webpage_information_complete = ""
|
| 914 |
|
| 915 |
if webpage_information_complete == "" and best_query_webpage_information_similarity_score > 0.30:
|
| 916 |
webpage_information_complete = best_webpage_information
|
|
|
|
| 1018 |
response = self.safe_app.invoke(state)
|
| 1019 |
agent_answer = response["output"]
|
| 1020 |
|
| 1021 |
+
if "answer: " in response["information"]:
|
| 1022 |
+
response["output"] = response["information"].split("answer: ")[-1].strip()
|
| 1023 |
+
|
| 1024 |
agent_answer = str(response)
|
| 1025 |
|
| 1026 |
# agent_answer = str(df)
|