Update AI Prompt System and Documentation
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m18s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m18s
- Added a new target architecture document for the AI Prompt System, detailing context types, composition, and planning phases. - Refactored the backend to utilize a shared function for loading AI prompt rows, reducing SQL duplication in the `exercise_ai` module. - Incremented the application version to 0.8.159 and updated the changelog to reflect these changes, including enhancements to the AI prompt management and documentation links.
This commit is contained in:
1 parent
2148d0aa7f
commit
cdeddc7cec
8 files changed
+268
-31
No files matched your search
+4
-20
@@ -17,6 +17,8 @@ from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Sequence,
|
||||
from fastapi import HTTPException
|
||||
|
||||
from openrouter_chat import OpenRouterError, normalize_openrouter_env, openrouter_chat_completion
|
||||
|
||||
from ai_prompt_runtime import load_ai_prompt_row
|
||||
from prompt_resolver import render_mustache_template
|
||||
|
||||
_LOGGER = logging.getLogger("shinkan.exercise_ai")
|
||||
@@ -489,24 +491,6 @@ def build_contextual_skills_catalog_block(
|
||||
return "\n".join(lines) if lines else "(keine aktiven Skills im Katalog)"
|
||||
|
||||
|
||||
def _load_prompt_row(cur, slug: str) -> Optional[Dict[str, Any]]:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT slug, display_name, template, output_format, active
|
||||
FROM ai_prompts
|
||||
WHERE slug = %s
|
||||
""",
|
||||
(slug,),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
if not row:
|
||||
return None
|
||||
d = dict(row)
|
||||
if not d.get("active", True):
|
||||
return None
|
||||
return d
|
||||
|
||||
|
||||
def build_exercise_placeholder_variables(
|
||||
cur,
|
||||
*,
|
||||
@@ -731,7 +715,7 @@ def run_exercise_ai_suggestion(
|
||||
)
|
||||
|
||||
if want_summary:
|
||||
prow = _load_prompt_row(cur, "exercise_summary")
|
||||
prow = load_ai_prompt_row(cur, "exercise_summary")
|
||||
if not prow:
|
||||
raise HTTPException(status_code=503, detail="Prompt exercise_summary nicht aktiv oder fehlt in DB.")
|
||||
try:
|
||||
@@ -771,7 +755,7 @@ def run_exercise_ai_suggestion(
|
||||
result["summary"] = {"text": text, "ai_generated": True, "model": model}
|
||||
|
||||
if want_skills:
|
||||
srow = _load_prompt_row(cur, "exercise_skill_suggestions")
|
||||
srow = load_ai_prompt_row(cur, "exercise_skill_suggestions")
|
||||
if not srow:
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
|
||||
Reference in new issue
Block a user