mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 05:40:17 +00:00
Use Slash Commands and Add Notes Slash Command (#463)
* Store conversation command options in an Enum * Move to slash commands instead of using @ to specify general commands * Calculate conversation command once & pass it as arg to child funcs * Add /notes command to respond using only knowledge base as context This prevents the chat model to try respond using it's general world knowledge only without any references pulled from the indexed knowledge base * Test general and notes slash commands in openai chat director tests * Update gpt4all tests to use md configuration * Add a /help tooltip * Add dynamic support for describing slash commands. Remove default and treat notes as the default type --------- Co-authored-by: sabaimran <narmiabas@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ from khoj.processor.conversation.openai.utils import (
|
||||
completion_with_backoff,
|
||||
)
|
||||
from khoj.processor.conversation.utils import generate_chatml_messages_with_context
|
||||
from khoj.utils.helpers import ConversationCommand, is_none_or_empty
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -108,6 +109,7 @@ def converse(
|
||||
api_key: Optional[str] = None,
|
||||
temperature: float = 0.2,
|
||||
completion_func=None,
|
||||
conversation_command=ConversationCommand.Notes,
|
||||
):
|
||||
"""
|
||||
Converse with user using OpenAI's ChatGPT
|
||||
@@ -117,8 +119,10 @@ def converse(
|
||||
compiled_references = "\n\n".join({f"# {item}" for item in references})
|
||||
|
||||
# Get Conversation Primer appropriate to Conversation Type
|
||||
if compiled_references == "":
|
||||
if conversation_command == ConversationCommand.General:
|
||||
conversation_primer = prompts.general_conversation.format(current_date=current_date, query=user_query)
|
||||
elif conversation_command == ConversationCommand.Notes and is_none_or_empty(compiled_references):
|
||||
return iter([prompts.no_notes_found.format()])
|
||||
else:
|
||||
conversation_primer = prompts.notes_conversation.format(
|
||||
current_date=current_date, query=user_query, references=compiled_references
|
||||
|
||||
Reference in New Issue
Block a user