mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Add logs for chat bot in verbose mode
This commit is contained in:
parent
6dc2a99d35
commit
5a686b7be9
2 changed files with 9 additions and 2 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue