Skip to content

Commit

Permalink
Changes suggested by Helene
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagan Singh committed Oct 18, 2024
1 parent ae05181 commit 52125d7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions backend/src/agents/web_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ async def web_general_search_core(search_query, llm, model) -> str:
answer_to_user = await answer_user_ques(search_query, llm, model)
answer_result = json.loads(answer_to_user)
if answer_result["status"] == "error":
return ""
response = {
"content": "Error in finding the answer.",
"ignore_validation": "false"
}
return json.dumps(response, indent=4)
logger.info(f'Answer found successfully {answer_result}')
valid_answer = json.loads(answer_result["response"]).get("is_valid", "")
if valid_answer:
Expand Down Expand Up @@ -149,7 +153,6 @@ async def web_pdf_download(pdf_url, llm, model) -> str:

async def web_scrape_core(url: str) -> str:
try:
logger.info(f"Scraping the price of the book from URL: {url}")
# Scrape the content from the provided URL
content = await perform_scrape(url)
if not content:
Expand All @@ -162,7 +165,6 @@ async def web_scrape_core(url: str) -> str:
}
return json.dumps(response, indent=4)
except Exception as e:
logger.error(f"Error in web_scrape_price_core: {e}")
return json.dumps({"status": "error", "error": str(e)})


Expand Down
2 changes: 1 addition & 1 deletion backend/src/prompts/templates/answer-user-ques.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Reply only in JSON format with the following structure:
}


Important: If the question is realted to real time data, the LLM should provide is_valid is false.
Important: If the question is related to real time data, the LLM should provide is_valid is false.
6 changes: 3 additions & 3 deletions backend/src/prompts/templates/best-tool.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Trust the information below completely (100% accurate)

Pick 1 tool (no more than 1) from the list below to complete this task.
Fit the correct parameters from the task to the tool arguments.
Ensure that numerical values are formatted correctly, including the use of currency symbols (e.g., "$") and units of measurement (e.g., "million") if applicable.
Ensure that numerical values are formatted correctly, including the use of currency symbols (e.g., "£") and units of measurement (e.g., "million") if applicable.
Parameters with required as False do not need to be fit.
Add if appropriate, but do not hallucinate arguments for these parameters

{{ tools }}

Important:
If the task involves financial data, ensure that all monetary values are expressed with appropriate currency (e.g., "$") and rounded to the nearest million if specified.
If the task involves scaling (e.g., thousands, millions), ensure that the extracted parameters reflect the appropriate scale (e.g., "$15 million", "$5000").
If the task involves financial data, ensure that all monetary values are expressed with appropriate currency (e.g., "£") and rounded to the nearest million if specified.
If the task involves scaling (e.g., thousands, millions), ensure that the extracted parameters reflect the appropriate scale (e.g., "£15 million", "£5000").

From the task you should be able to extract the parameters. If it is data driven, it should be turned into a cypher query

Expand Down
2 changes: 1 addition & 1 deletion backend/src/prompts/templates/create-search-term.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Reply only in JSON format, following this structure:
{
"search_term": "The optimized Google search term based on the user's question",
"reasoning": "A sentence on why you chose that search term"
}
}
4 changes: 2 additions & 2 deletions backend/src/prompts/templates/intent.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The question is:

{{ question }}

The prvious chat history is:
The previous chat history is:

{{ chat_history }}

Expand Down Expand Up @@ -84,4 +84,4 @@ Finally, if no tool fits the task, return the following:
}

Important:
Please always create the last intent to append the retrieved info in a 'conversation-history.txt' file and make sure this history file is always 'conversation-history.txt'
Please always create the last intent to append the retrieved info in a 'conversation-history.txt' file and make sure this history file is always named 'conversation-history.txt'
1 change: 1 addition & 0 deletions backend/src/prompts/templates/math-solver.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ query: Round 81.462 billion to the nearest million
"steps": "1. Convert 81.462 billion to million by multiplying by 1000. Round the result to the nearest million.",
"reasoning": "Rounding to the nearest million ensures that the result is represented in a more practical figure, without exceeding or falling short of the actual value."
}

2 changes: 1 addition & 1 deletion backend/src/prompts/templates/tool-selection-format.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Reply only in json with the following format, in the tool_paramters please include the curreny and measuring scale used in the content provided.:
Reply only in json with the following format, in the tool_parameters please include the currency and measuring scale used in the content provided.:


{
Expand Down
2 changes: 1 addition & 1 deletion backend/src/prompts/templates/validator.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Reasoning: The answer is for Spotify not Amazon.
Task: Please find tesla's revenue every year since its creation.
Answer: Tesla's annual revenue history from FY 2008 to FY 2023 is available, with figures for 2008 through 2020 taken from previous annual reports.
Response: False
Reasoning: The answer is not prvoding any actual figures but just talk about the figures.
Reasoning: The answer is not providing any actual figures but just talk about the figures.

Task: Please find tesla's revenue every year since its creation in the US dollars.
Answer: Tesla's annual revenue in USD since its creation is as follows: 2024 (TTM) $75.92 billion, 2023 $75.95 billion, 2022 $67.33 billion, 2021 $39.76 billion, 2020 $23.10 billion, 2019 $18.52 billion, 2018 $16.81 billion, 2017 $8.70 billion, 2016 $5.67 billion, 2015 $2.72 billion, 2014 $2.05 billion, 2013 $1.21 billion, 2012 $0.25 billion, 2011 $0.13 billion, 2010 $75.88 million, 2009 $69.73 million.
Expand Down

0 comments on commit 52125d7

Please sign in to comment.