diff --git a/src/main.py b/src/main.py index f08a30de..dea7cf63 100644 --- a/src/main.py +++ b/src/main.py @@ -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) diff --git a/src/processor/conversation/gpt.py b/src/processor/conversation/gpt.py index 4782abfb..5a44f2c3 100644 --- a/src/processor/conversation/gpt.py +++ b/src/processor/conversation/gpt.py @@ -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(