Spaces:
Running
Running
Update Original_OpenAPI_DB.py
Browse files- Original_OpenAPI_DB.py +14 -5
Original_OpenAPI_DB.py
CHANGED
@@ -236,13 +236,19 @@ def search_azure_database_content(query: str) -> list:
|
|
236 |
""", (f"%{query}%",))
|
237 |
|
238 |
for row in cursor.fetchall():
|
239 |
-
|
240 |
"title": row.Title or "No title",
|
241 |
-
"url": row.URL or "",
|
242 |
"type": row.ContentType,
|
243 |
"source_table": row.SourceTable,
|
244 |
"similarity": 0.8
|
245 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
conn.close()
|
248 |
logging.info(f"Found {len(results)} results from Azure database")
|
@@ -577,9 +583,12 @@ async def agentic_hockey_chat(user_active_role: str, user_team: str, user_prompt
|
|
577 |
}
|
578 |
|
579 |
# Add URL for multimedia items, content for others
|
580 |
-
if item["type"] == "multimedia"
|
581 |
-
|
|
|
|
|
582 |
else:
|
|
|
583 |
content_detail["content"] = item.get("content", "")
|
584 |
|
585 |
recommended_content_details.append(content_detail)
|
|
|
236 |
""", (f"%{query}%",))
|
237 |
|
238 |
for row in cursor.fetchall():
|
239 |
+
multimedia_result = {
|
240 |
"title": row.Title or "No title",
|
|
|
241 |
"type": row.ContentType,
|
242 |
"source_table": row.SourceTable,
|
243 |
"similarity": 0.8
|
244 |
+
}
|
245 |
+
# Ensure URL is properly included for multimedia items
|
246 |
+
if row.URL:
|
247 |
+
multimedia_result["url"] = row.URL
|
248 |
+
else:
|
249 |
+
multimedia_result["url"] = ""
|
250 |
+
|
251 |
+
results.append(multimedia_result)
|
252 |
|
253 |
conn.close()
|
254 |
logging.info(f"Found {len(results)} results from Azure database")
|
|
|
583 |
}
|
584 |
|
585 |
# Add URL for multimedia items, content for others
|
586 |
+
if item["type"] == "multimedia":
|
587 |
+
# Ensure URL is included for multimedia items from Azure DB
|
588 |
+
content_detail["url"] = item.get("url", "")
|
589 |
+
logging.debug(f"Multimedia item: {item['title']} - URL: {content_detail['url']}")
|
590 |
else:
|
591 |
+
# For exercise and serie items, include content/description
|
592 |
content_detail["content"] = item.get("content", "")
|
593 |
|
594 |
recommended_content_details.append(content_detail)
|