Spaces:
Sleeping
Sleeping
ho
Browse files
app.py
CHANGED
@@ -21,9 +21,12 @@ async def chat_interface(user_role, user_team, user_prompt):
|
|
21 |
try:
|
22 |
# Load resources on first use to save memory
|
23 |
if not resources_loaded:
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
# Call the main chat function
|
29 |
result = await agentic_hockey_chat(user_role, user_team, user_prompt)
|
@@ -36,7 +39,7 @@ async def chat_interface(user_role, user_team, user_prompt):
|
|
36 |
rec_html = ""
|
37 |
if recommendations:
|
38 |
rec_html = "<h3>🏒 Recommended Videos:</h3><ul>"
|
39 |
-
for
|
40 |
title = rec.get('title', 'No title')
|
41 |
url = rec.get('url', '#')
|
42 |
similarity = rec.get('similarity', 0)
|
@@ -46,7 +49,9 @@ async def chat_interface(user_role, user_team, user_prompt):
|
|
46 |
return ai_response, rec_html
|
47 |
|
48 |
except Exception as e:
|
49 |
-
|
|
|
|
|
50 |
|
51 |
def sync_chat_interface(user_role, user_team, user_prompt):
|
52 |
"""Synchronous wrapper for Gradio"""
|
|
|
21 |
try:
|
22 |
# Load resources on first use to save memory
|
23 |
if not resources_loaded:
|
24 |
+
try:
|
25 |
+
from OpenAPI_DB import load_resources
|
26 |
+
load_resources()
|
27 |
+
resources_loaded = True
|
28 |
+
except ImportError as import_err:
|
29 |
+
return f"Import Error: {str(import_err)}. Please check if all required packages are installed.", "Unable to load ML models."
|
30 |
|
31 |
# Call the main chat function
|
32 |
result = await agentic_hockey_chat(user_role, user_team, user_prompt)
|
|
|
39 |
rec_html = ""
|
40 |
if recommendations:
|
41 |
rec_html = "<h3>🏒 Recommended Videos:</h3><ul>"
|
42 |
+
for rec in recommendations[:5]:
|
43 |
title = rec.get('title', 'No title')
|
44 |
url = rec.get('url', '#')
|
45 |
similarity = rec.get('similarity', 0)
|
|
|
49 |
return ai_response, rec_html
|
50 |
|
51 |
except Exception as e:
|
52 |
+
import traceback
|
53 |
+
error_details = traceback.format_exc()
|
54 |
+
return f"Error: {str(e)}\n\nDetails:\n{error_details}", "No recommendations available due to error."
|
55 |
|
56 |
def sync_chat_interface(user_role, user_team, user_prompt):
|
57 |
"""Synchronous wrapper for Gradio"""
|