Spaces:
Sleeping
Sleeping
Update qa.py
Browse files
qa.py
CHANGED
@@ -36,8 +36,8 @@ def transcribe_audio_deepgram(local_audio_path: str) -> str:
|
|
36 |
|
37 |
def call_llm_for_qa(conversation_so_far: str, user_question: str) -> dict:
|
38 |
"""
|
39 |
-
|
40 |
-
Returns a Python dict
|
41 |
"""
|
42 |
system_prompt = f"""
|
43 |
You are John, the guest speaker. The user is asking a follow-up question.
|
@@ -51,9 +51,9 @@ def call_llm_for_qa(conversation_so_far: str, user_question: str) -> dict:
|
|
51 |
{{ "speaker": "John", "text": "Sure, here's my answer..." }}
|
52 |
"""
|
53 |
|
54 |
-
from utils import call_groq_api_for_qa
|
55 |
|
56 |
-
raw_json_response = call_groq_api_for_qa(system_prompt)
|
57 |
# Expect a JSON string: {"speaker": "John", "text": "some short answer"}
|
58 |
response_dict = json.loads(raw_json_response)
|
59 |
return response_dict
|
@@ -84,5 +84,6 @@ def handle_qa_exchange(user_question: str) -> (bytes, str):
|
|
84 |
audio_file_path = generate_audio_mp3(answer_text, "John") # always John
|
85 |
with open(audio_file_path, "rb") as f:
|
86 |
audio_bytes = f.read()
|
|
|
87 |
|
88 |
return (audio_bytes, answer_text)
|
|
|
36 |
|
37 |
def call_llm_for_qa(conversation_so_far: str, user_question: str) -> dict:
|
38 |
"""
|
39 |
+
Calls Groq LLM to answer a follow-up question.
|
40 |
+
Returns a Python dict: {"speaker": "John", "text": "..."}
|
41 |
"""
|
42 |
system_prompt = f"""
|
43 |
You are John, the guest speaker. The user is asking a follow-up question.
|
|
|
51 |
{{ "speaker": "John", "text": "Sure, here's my answer..." }}
|
52 |
"""
|
53 |
|
54 |
+
from utils import call_groq_api_for_qa # Import from utils
|
55 |
|
56 |
+
raw_json_response = call_groq_api_for_qa(system_prompt) # Corrected call
|
57 |
# Expect a JSON string: {"speaker": "John", "text": "some short answer"}
|
58 |
response_dict = json.loads(raw_json_response)
|
59 |
return response_dict
|
|
|
84 |
audio_file_path = generate_audio_mp3(answer_text, "John") # always John
|
85 |
with open(audio_file_path, "rb") as f:
|
86 |
audio_bytes = f.read()
|
87 |
+
os.remove(audio_file_path) #Added to remove audio files
|
88 |
|
89 |
return (audio_bytes, answer_text)
|