Spaces:
Sleeping
Sleeping
Ali Hashhash commited on
Commit ·
8c1ee4e
1
Parent(s): f726182
feat: implement NoteGenerator for LLM-based transcript summarization and add note management routes
Browse files
src/api/notes_routes.py
CHANGED
|
@@ -281,8 +281,7 @@ async def process_video_task(
|
|
| 281 |
from src.utils.model_loader import INFERENCE_MODE
|
| 282 |
|
| 283 |
if INFERENCE_MODE == "groq":
|
| 284 |
-
|
| 285 |
-
key_points_list = parse_key_points_from_markdown(summary_json.get("summary", ""))
|
| 286 |
else:
|
| 287 |
segments = summary_json.get("segments", [])
|
| 288 |
key_points_list = [
|
|
@@ -298,13 +297,12 @@ async def process_video_task(
|
|
| 298 |
)
|
| 299 |
|
| 300 |
if INFERENCE_MODE == "groq":
|
| 301 |
-
|
| 302 |
-
category = classify_topic_groq(resolved_video_title, summary_json.get("summary", ""))
|
| 303 |
categories = [category]
|
| 304 |
else:
|
| 305 |
from src.categorization.topic_classifier import classify_topics
|
| 306 |
raw_topics = summary_json.get("topics", [])
|
| 307 |
-
categories = classify_topics(raw_topics) if raw_topics else ["Education
|
| 308 |
|
| 309 |
_set_task_status(task_id, "complete", "Generation completed successfully.")
|
| 310 |
tasks[task_id]["notes"] = final_markdown
|
|
|
|
| 281 |
from src.utils.model_loader import INFERENCE_MODE
|
| 282 |
|
| 283 |
if INFERENCE_MODE == "groq":
|
| 284 |
+
key_points_list = summary_json.get("key_points", [])
|
|
|
|
| 285 |
else:
|
| 286 |
segments = summary_json.get("segments", [])
|
| 287 |
key_points_list = [
|
|
|
|
| 297 |
)
|
| 298 |
|
| 299 |
if INFERENCE_MODE == "groq":
|
| 300 |
+
category = summary_json.get("suggested_category", "Education")
|
|
|
|
| 301 |
categories = [category]
|
| 302 |
else:
|
| 303 |
from src.categorization.topic_classifier import classify_topics
|
| 304 |
raw_topics = summary_json.get("topics", [])
|
| 305 |
+
categories = classify_topics(raw_topics) if raw_topics else ["Education"]
|
| 306 |
|
| 307 |
_set_task_status(task_id, "complete", "Generation completed successfully.")
|
| 308 |
tasks[task_id]["notes"] = final_markdown
|
src/summarization/note_generator.py
CHANGED
|
@@ -406,6 +406,11 @@ class NoteGenerator:
|
|
| 406 |
|
| 407 |
# 3. Detect language from the transcript (used by UI and metadata)
|
| 408 |
detected_language = self._detect_language(transcript_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
if INFERENCE_MODE == "groq":
|
| 411 |
conclusion_text = (
|
|
@@ -433,11 +438,12 @@ class NoteGenerator:
|
|
| 433 |
candidate = {
|
| 434 |
"title": video_title,
|
| 435 |
"detected_language": detected_language,
|
| 436 |
-
"summary": overall_summary,
|
| 437 |
"segments": segments_list,
|
| 438 |
-
"suggested_category": "
|
| 439 |
"conclusion": conclusion_text,
|
| 440 |
"topics": topics_list,
|
|
|
|
| 441 |
}
|
| 442 |
|
| 443 |
# 3. VALIDATE — enforce the schema contract before returning
|
|
|
|
| 406 |
|
| 407 |
# 3. Detect language from the transcript (used by UI and metadata)
|
| 408 |
detected_language = self._detect_language(transcript_text)
|
| 409 |
+
|
| 410 |
+
# Override detected language based on the REDUCE step if available
|
| 411 |
+
llm_lang = overall_summary.get("language")
|
| 412 |
+
if llm_lang:
|
| 413 |
+
detected_language = "Arabic" if llm_lang == "ar" else "English"
|
| 414 |
|
| 415 |
if INFERENCE_MODE == "groq":
|
| 416 |
conclusion_text = (
|
|
|
|
| 438 |
candidate = {
|
| 439 |
"title": video_title,
|
| 440 |
"detected_language": detected_language,
|
| 441 |
+
"summary": overall_summary.get("markdown_summary", ""),
|
| 442 |
"segments": segments_list,
|
| 443 |
+
"suggested_category": overall_summary.get("category", "Education"),
|
| 444 |
"conclusion": conclusion_text,
|
| 445 |
"topics": topics_list,
|
| 446 |
+
"key_points": overall_summary.get("key_points", []),
|
| 447 |
}
|
| 448 |
|
| 449 |
# 3. VALIDATE — enforce the schema contract before returning
|