feat(prompts): implement TOML-backed prompt loading and refactor message generation

This commit is contained in:
2026-07-24 11:38:51 -04:00
parent 94f18722e4
commit 8073144e2b
7 changed files with 83 additions and 24 deletions
+2 -10
View File
@@ -6,6 +6,7 @@ import logging
from typing import TYPE_CHECKING
from python.ebook_search.llm_interface import request_chat_completion
from python.ebook_search.prompts import load_prompt
if TYPE_CHECKING:
import httpx
@@ -42,16 +43,7 @@ async def answer_query(
content = await request_chat_completion(
client,
config,
[
{
"role": "system",
"content": (
"Answer only from the provided context. Cite sources with bracketed numbers like [1]. "
"If the context is insufficient, say so."
),
},
{"role": "user", "content": f"Question:\n{query}\n\nContext:\n{context}"},
],
load_prompt("answer").messages(query=query, context=context),
)
logger.info(f"ebook_answer_request_complete {config.chat_model=} answer_length={len(content)}")