Skip to content

Commit

Permalink
Make chat actors generate valid json with more local models
Browse files Browse the repository at this point in the history
Improve tool, online search, webpage links, docs search chat actor
prompts. Ensure works with hermes-2-pro and llama-3.

Be more specific about generating JSON and not saying anything else.
  • Loading branch information
debanjum committed Apr 24, 2024
1 parent a2e4e4b commit 4f7237b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/khoj/processor/conversation/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
- Add as much context from the previous questions and answers as required into your search queries.
- Break messages into multiple search queries when required to retrieve the relevant information.
- Add date filters to your search queries from questions and answers when required to retrieve the relevant information.
- Share relevant search queries as a JSON list of strings. Do not say anything else.
Current Date: {current_date}
User's Location: {location}
Expand Down Expand Up @@ -199,7 +200,7 @@
Chat History:
{chat_history}
What searches will you perform to answer the following question, using the chat history as reference? Respond with relevant search queries as list of strings.
What searches will you perform to answer the following question, using the chat history as reference? Respond only with relevant search queries as a valid JSON list of strings.
Q: {query}
""".strip()
)
Expand Down Expand Up @@ -370,7 +371,7 @@
Q: What is the first element of the periodic table?
Khoj: {{"source": ["general"]}}
Now it's your turn to pick the data sources you would like to use to answer the user's question. Respond with data sources as a list of strings in a JSON object.
Now it's your turn to pick the data sources you would like to use to answer the user's question. Provide the data sources as a list of strings in a JSON object. Do not say anything else.
Chat History:
{chat_history}
Expand Down Expand Up @@ -415,7 +416,7 @@
Q: What's the latest news on r/worldnews?
Khoj: {{"links": ["https://www.reddit.com/r/worldnews/"]}}
Now it's your turn to share actual webpage urls you'd like to read to answer the user's question.
Now it's your turn to share actual webpage urls you'd like to read to answer the user's question. Provide them as a list of strings in a JSON object. Do not say anything else.
History:
{chat_history}
Expand All @@ -435,7 +436,7 @@
- Official, up-to-date information about you, Khoj, is available at site:khoj.dev, github or pypi.
What Google searches, if any, will you need to perform to answer the user's question?
Provide search queries as a JSON list of strings
Provide search queries as a list of strings in a JSON object.
Current Date: {current_date}
User's Location: {location}
Expand Down Expand Up @@ -482,7 +483,7 @@
Q: How many oranges would fit in NASA's Saturn V rocket?
Khoj: {{"queries": ["volume of an orange", "volume of saturn v rocket"]}}
Now it's your turn to construct Google search queries to answer the user's question.
Now it's your turn to construct Google search queries to answer the user's question. Provide them as a list of strings in a JSON object. Do not say anything else.
History:
{chat_history}
Expand Down

0 comments on commit 4f7237b

Please sign in to comment.