mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Add logs for chat bot in verbose mode
This commit is contained in:
@@ -103,11 +103,16 @@ def chat(q: str):
|
||||
meta_log = processor_config.conversation.meta_log
|
||||
|
||||
# Converse with OpenAI GPT
|
||||
metadata = understand(q, api_key=processor_config.conversation.openai_api_key)
|
||||
metadata = understand(q, api_key=processor_config.conversation.openai_api_key, verbose=verbose)
|
||||
if verbose > 1:
|
||||
print(f'Understood: {get_from_dict(metadata, "intent")}')
|
||||
|
||||
if get_from_dict(metadata, "intent", "memory-type") == "notes":
|
||||
query = get_from_dict(metadata, "intent", "query")
|
||||
result_list = search(query, n=1, t=SearchType.Notes)
|
||||
collated_result = "\n".join([item["Entry"] for item in result_list])
|
||||
if verbose > 1:
|
||||
print(f'Semantically Similar Notes:\n{collated_result}')
|
||||
gpt_response = summarize(collated_result, summary_type="notes", user_query=q, api_key=processor_config.conversation.openai_api_key)
|
||||
else:
|
||||
gpt_response = converse(q, chat_session, api_key=processor_config.conversation.openai_api_key)
|
||||
|
||||
@@ -36,7 +36,7 @@ def summarize(text, summary_type, user_query=None, api_key=None, temperature=0.5
|
||||
return str(story).replace("\n\n", "")
|
||||
|
||||
|
||||
def understand(text, api_key=None, temperature=0.5, max_tokens=100):
|
||||
def understand(text, api_key=None, temperature=0.5, max_tokens=100, verbose=0):
|
||||
"""
|
||||
Understand user input using OpenAI's GPT
|
||||
"""
|
||||
@@ -46,6 +46,8 @@ def understand(text, api_key=None, temperature=0.5, max_tokens=100):
|
||||
|
||||
# Setup Prompt with Understand Primer
|
||||
prompt = message_to_prompt(text, understand_primer, start_sequence="\nA:", restart_sequence="\nQ:")
|
||||
if verbose > 1:
|
||||
print(f"Message -> Prompt: {text} -> {prompt}")
|
||||
|
||||
# Get Response from GPT
|
||||
response = openai.Completion.create(
|
||||
|
||||
Reference in New Issue
Block a user