diff --git a/src/khoj/processor/conversation/prompts.py b/src/khoj/processor/conversation/prompts.py index a95bbe73..07e09436 100644 --- a/src/khoj/processor/conversation/prompts.py +++ b/src/khoj/processor/conversation/prompts.py @@ -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. diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 0736e68f..33435c5b 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -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.