Spaces:
Running on Zero
Running on Zero
Deploy combined llama.cpp prompt runtime
Browse files- src/pipeline.py +13 -5
src/pipeline.py
CHANGED
|
@@ -3,12 +3,12 @@
|
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
from datetime import datetime
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
|
| 8 |
from src.config import TRACE_DIR, get_runtime_settings, runtime_status
|
| 9 |
from src.models.llama_cpp_runner import (
|
| 10 |
-
|
| 11 |
-
generate_persona,
|
| 12 |
get_text_runtime_fallbacks,
|
| 13 |
reset_text_runtime_fallbacks,
|
| 14 |
)
|
|
@@ -31,8 +31,7 @@ def generate_object_diary(
|
|
| 31 |
vision_result = understand_object_with_metadata(image_path, description, settings=settings)
|
| 32 |
object_understanding = vision_result.object_understanding
|
| 33 |
reset_text_runtime_fallbacks()
|
| 34 |
-
persona =
|
| 35 |
-
diary = generate_diary(persona, mode)
|
| 36 |
text_fallbacks = get_text_runtime_fallbacks()
|
| 37 |
trace = build_trace(
|
| 38 |
image_path=image_path,
|
|
@@ -63,7 +62,16 @@ def generate_object_diary(
|
|
| 63 |
|
| 64 |
|
| 65 |
def format_diary_markdown(title: str, english: str, chinese: str) -> str:
|
| 66 |
-
return f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
def _runtime_fallbacks(
|
|
|
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
from datetime import datetime
|
| 6 |
+
from html import escape
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
from src.config import TRACE_DIR, get_runtime_settings, runtime_status
|
| 10 |
from src.models.llama_cpp_runner import (
|
| 11 |
+
generate_persona_and_diary,
|
|
|
|
| 12 |
get_text_runtime_fallbacks,
|
| 13 |
reset_text_runtime_fallbacks,
|
| 14 |
)
|
|
|
|
| 31 |
vision_result = understand_object_with_metadata(image_path, description, settings=settings)
|
| 32 |
object_understanding = vision_result.object_understanding
|
| 33 |
reset_text_runtime_fallbacks()
|
| 34 |
+
persona, diary = generate_persona_and_diary(object_understanding, mode)
|
|
|
|
| 35 |
text_fallbacks = get_text_runtime_fallbacks()
|
| 36 |
trace = build_trace(
|
| 37 |
image_path=image_path,
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
def format_diary_markdown(title: str, english: str, chinese: str) -> str:
|
| 65 |
+
return f"""
|
| 66 |
+
<section class="diary-entry">
|
| 67 |
+
<h2>{escape(title)}</h2>
|
| 68 |
+
<p>{escape(english)}</p>
|
| 69 |
+
<section class="lang-zh block zh-helper">
|
| 70 |
+
<strong>中文辅助</strong>
|
| 71 |
+
<p>{escape(chinese)}</p>
|
| 72 |
+
</section>
|
| 73 |
+
</section>
|
| 74 |
+
"""
|
| 75 |
|
| 76 |
|
| 77 |
def _runtime_fallbacks(
|