Add the subject generation prompt and helper method

This commit is contained in:
sabaimran 2024-05-01 13:55:32 +05:30
parent c30ba2e551
commit a86f95117e
2 changed files with 32 additions and 0 deletions

View file

@ -575,6 +575,26 @@ Khoj:
""".strip()
)
subject_generation = PromptTemplate.from_template(
"""
You are an extremely smart and helpful title generator assistant. Given a user query, extract the subject or title of the task to be performed.
- Use the user query to infer the subject or title of the task.
# Examples:
User: Show a new Calvin and Hobbes quote every morning at 9am. My Current Location: Shanghai, China
Khoj: Your daily Calvin and Hobbes Quote
User: Notify me when version 2.0.0 of the sentence transformers python package is released. My Current Location: Mexico City, Mexico
Khoj: Sentence Transformers Python Package Version 2.0.0 Release
User: Gather the latest tech news on the first sunday of every month.
Khoj: Your Monthly Dose of Tech News
User Query: {query}
Khoj:
""".strip()
)
to_notify_or_not = PromptTemplate.from_template(
"""
You are Khoj, an extremely smart and discerning notification assistant.

View file

@ -187,6 +187,18 @@ async def agenerate_chat_response(*args):
return await loop.run_in_executor(executor, generate_chat_response, *args)
async def acreate_title_from_query(query: str) -> str:
"""
Create a title from the given query
"""
title_generation_prompt = prompts.subject_generation.format(query=query)
with timer("Chat actor: Generate title from query", logger):
response = await send_message_to_model_wrapper(title_generation_prompt)
return response.strip()
async def aget_relevant_information_sources(query: str, conversation_history: dict, is_task: bool):
"""
Given a query, determine which of the available tools the agent should use in order to answer appropriately.