Parimal Kalpande commited on
Commit ·
d075172
1
Parent(s): 5cc9aac
MAJOR: Downgrade to Gradio 3.50.2 and update all API calls for compatibility to fix persistent JSON schema errors
Browse files- README.md +1 -1
- app.py +7 -10
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🎯
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.50.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
app.py
CHANGED
|
@@ -12,14 +12,11 @@ from modules.llm_handler import generate_coaching_question, evaluate_response, g
|
|
| 12 |
from modules.report_generator import generate_pdf_report
|
| 13 |
|
| 14 |
def convert_to_gradio_format(messages):
|
| 15 |
-
"""Convert message format to be compatible with Gradio
|
| 16 |
if not messages:
|
| 17 |
return []
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
if messages and isinstance(messages[0], (list, tuple)) and len(messages[0]) == 2:
|
| 21 |
-
return messages
|
| 22 |
-
|
| 23 |
result = []
|
| 24 |
user_msg = None
|
| 25 |
|
|
@@ -42,7 +39,7 @@ def convert_to_gradio_format(messages):
|
|
| 42 |
return result
|
| 43 |
|
| 44 |
def add_message_to_history(history, role, content):
|
| 45 |
-
"""Add a message to history and convert to Gradio format"""
|
| 46 |
if not history:
|
| 47 |
history = []
|
| 48 |
|
|
@@ -244,7 +241,7 @@ with gr.Blocks() as app:
|
|
| 244 |
user_name = gr.Textbox(label="Your Name")
|
| 245 |
|
| 246 |
coaching_type_dd = gr.Dropdown(
|
| 247 |
-
config.COACHING_TYPES,
|
| 248 |
label="Product Management Focus Area"
|
| 249 |
)
|
| 250 |
gr.Markdown("*Choose the area you want to improve*")
|
|
@@ -266,7 +263,7 @@ with gr.Blocks() as app:
|
|
| 266 |
with gr.Row():
|
| 267 |
# Simplified audio input
|
| 268 |
audio_in = gr.Audio(
|
| 269 |
-
|
| 270 |
type="filepath",
|
| 271 |
label="🎙️ Record Your Response"
|
| 272 |
)
|
|
@@ -291,8 +288,8 @@ with gr.Blocks() as app:
|
|
| 291 |
outputs=[audio_in, status_text]
|
| 292 |
)
|
| 293 |
|
| 294 |
-
# Simplified audio handling
|
| 295 |
-
audio_in.
|
| 296 |
fn=handle_coaching_turn,
|
| 297 |
inputs=[audio_in, chatbot, state],
|
| 298 |
outputs=[chatbot, state, audio_in, download_pdf_btn, audio_out]
|
|
|
|
| 12 |
from modules.report_generator import generate_pdf_report
|
| 13 |
|
| 14 |
def convert_to_gradio_format(messages):
|
| 15 |
+
"""Convert message format to be compatible with Gradio 3.x"""
|
| 16 |
if not messages:
|
| 17 |
return []
|
| 18 |
|
| 19 |
+
# For Gradio 3.x, use simple string pairs [user, assistant]
|
|
|
|
|
|
|
|
|
|
| 20 |
result = []
|
| 21 |
user_msg = None
|
| 22 |
|
|
|
|
| 39 |
return result
|
| 40 |
|
| 41 |
def add_message_to_history(history, role, content):
|
| 42 |
+
"""Add a message to history and convert to Gradio 3.x format"""
|
| 43 |
if not history:
|
| 44 |
history = []
|
| 45 |
|
|
|
|
| 241 |
user_name = gr.Textbox(label="Your Name")
|
| 242 |
|
| 243 |
coaching_type_dd = gr.Dropdown(
|
| 244 |
+
choices=config.COACHING_TYPES,
|
| 245 |
label="Product Management Focus Area"
|
| 246 |
)
|
| 247 |
gr.Markdown("*Choose the area you want to improve*")
|
|
|
|
| 263 |
with gr.Row():
|
| 264 |
# Simplified audio input
|
| 265 |
audio_in = gr.Audio(
|
| 266 |
+
source="microphone",
|
| 267 |
type="filepath",
|
| 268 |
label="🎙️ Record Your Response"
|
| 269 |
)
|
|
|
|
| 288 |
outputs=[audio_in, status_text]
|
| 289 |
)
|
| 290 |
|
| 291 |
+
# Simplified audio handling for Gradio 3.x
|
| 292 |
+
audio_in.change(
|
| 293 |
fn=handle_coaching_turn,
|
| 294 |
inputs=[audio_in, chatbot, state],
|
| 295 |
outputs=[chatbot, state, audio_in, download_pdf_btn, audio_out]
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio==
|
| 2 |
groq
|
| 3 |
openai-whisper
|
| 4 |
pydub
|
|
|
|
| 1 |
+
gradio==3.50.2
|
| 2 |
groq
|
| 3 |
openai-whisper
|
| 4 |
pydub
|