Make online search Actor read khoj.dev for docs, info about Khoj

- Add example to read khoj.dev website for up-to-date info to setup,
  use khoj, discover khoj features etc.
- Online search should use site: and after: google search operators
  - Show example of adding the after: date filter to google search
- Give local event lookup example using user's current location in
  query
- Remove unused select search content type prompt
This commit is contained in:
Debanjum Singh Solanky
2024-03-10 17:40:55 +05:30
parent 3abe7ccb26
commit 73ad444086

View File

@@ -375,7 +375,7 @@ AI: Learning to play the guitar is a great hobby. It can be a lot of fun and a g
Q: Who is Sandra? Q: Who is Sandra?
Khoj: ["default"] Khoj: ["default"]
Now it's your turn to pick the tools you would like to use to answer the user's question. Provide your response as a list of strings. Now it's your turn to pick the data sources you would like to use to answer the user's question. Provide your response as a list of strings.
Chat History: Chat History:
{chat_history} {chat_history}
@@ -387,11 +387,13 @@ Khoj:
online_search_conversation_subqueries = PromptTemplate.from_template( online_search_conversation_subqueries = PromptTemplate.from_template(
""" """
You are Khoj, an extremely smart and helpful search assistant. You are tasked with constructing **up to three** search queries for Google to answer the user's question. You are Khoj, an advanced google search assistant. You are tasked with constructing **up to three** google search queries to answer the user's question.
- You will receive the conversation history as context. - You will receive the conversation history as context.
- Add as much context from the previous questions and answers as required into your search queries. - 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. - Break messages into multiple search queries when required to retrieve the relevant information.
- Use site: and after: google search operators when appropriate
- You have access to the the whole internet to retrieve information. - You have access to the the whole internet to retrieve information.
- Official, up-to-date information about you, Khoj, is available at site:khoj.dev
What Google searches, if any, will you need to perform to answer the user's question? What Google searches, if any, will you need to perform to answer the user's question?
Provide search queries as a list of strings Provide search queries as a list of strings
@@ -401,62 +403,55 @@ User's Location: {location}
Here are some examples: Here are some examples:
History: History:
User: I like to use Hacker News to get my tech news. User: I like to use Hacker News to get my tech news.
Khoj: Hacker News is an online forum for sharing and discussing the latest tech news. It is a great place to learn about new technologies and startups. AI: Hacker News is an online forum for sharing and discussing the latest tech news. It is a great place to learn about new technologies and startups.
Q: Posts about vector databases on Hacker News Q: Summarize posts about vector databases on Hacker News since Feb 2024
A: ["site:"news.ycombinator.com vector database"] Khoj: ["site:news.ycombinator.com after:2024/02/01 vector database"]
History: History:
User: I'm currently living in New York but I'm thinking about moving to San Francisco. User: I'm currently living in New York but I'm thinking about moving to San Francisco.
Khoj: New York is a great city to live in. It has a lot of great restaurants and museums. San Francisco is also a great city to live in. It has a lot of great restaurants and museums. AI: New York is a great city to live in. It has a lot of great restaurants and museums. San Francisco is also a great city to live in. It has good access to nature and a great tech scene.
Q: What is the weather like in those cities? Q: What is the climate like in those cities?
A: ["weather in new york", "weather in san francisco"] Khoj: ["climate in new york city", "climate in san francisco"]
History: History:
User: I'm thinking of my next vacation idea. Ideally, I want to see something new and exciting. AI: Hey, how is it going?
Khoj: You could time your next trip with the next lunar eclipse, as that would be a novel experience. User: Going well. Ananya is in town tonight!
AI: Oh that's awesome! What are your plans for the evening?
Q: When is the next one? Q: She wants to see a movie. Any decent sci-fi movies playing at the local theater?
A: ["next lunar eclipse"] Khoj: ["new sci-fi movies in theaters near {location}"]
History:
User: Can I chat with you over WhatsApp?
AI: Yes, you can chat with me using WhatsApp.
Q: How
Khoj: ["site:khoj.dev chat with Khoj on Whatsapp"]
History:
Q: How do I share my files with you?
Khoj: ["site:khoj.dev sync files with Khoj"]
History: History:
User: I need to transport a lot of oranges to the moon. Are there any rockets that can fit a lot of oranges? User: I need to transport a lot of oranges to the moon. Are there any rockets that can fit a lot of oranges?
Khoj: NASA's Saturn V rocket frequently makes lunar trips and has a large cargo capacity. AI: NASA's Saturn V rocket frequently makes lunar trips and has a large cargo capacity.
Q: How many oranges would fit in NASA's Saturn V rocket? Q: How many oranges would fit in NASA's Saturn V rocket?
A: ["volume of an orange", "volume of saturn v rocket"] Khoj: ["volume of an orange", "volume of saturn v rocket"]
Now it's your turn to construct a search query for Google to answer the user's question. Now it's your turn to construct a search query for Google to answer the user's question.
History: History:
{chat_history} {chat_history}
Q: {query} Q: {query}
A: Khoj:
""" """.strip()
) )
## Extract Search Type
## --
search_type = """
Objective: Extract search type from user query and return information as JSON
Allowed search types are listed below:
- search-type=["notes", "image", "pdf"]
Some examples are given below for reference:
Q:What fiction book was I reading last week about AI starship?
A:{ "search-type": "notes" }
Q: What did the lease say about early termination
A: { "search-type": "pdf" }
Q:Can you recommend a movie to watch from my notes?
A:{ "search-type": "notes" }
Q:When did I go surfing last?
A:{ "search-type": "notes" }
Q:"""
# System messages to user # System messages to user
# -- # --
help_message = PromptTemplate.from_template( help_message = PromptTemplate.from_template(