v1.0.113: prompt_version in spec_events — provenance (who created what with which prompt)
This commit is contained in:
@@ -19,8 +19,8 @@ LUCEE_URL = "https://contractor.luceek8s.dev.nubes.ru"
|
||||
|
||||
|
||||
def call_llm(current_spec, doc_text):
|
||||
"""Вызов LLM API. Возвращает {mode, ops} или кидает исключение."""
|
||||
prompt = build_prompt(current_spec, doc_text)
|
||||
"""Вызов LLM API. Возвращает ({mode, ops}, prompt_id) или кидает исключение."""
|
||||
prompt, prompt_id = build_prompt(current_spec, doc_text)
|
||||
payload = {
|
||||
"model": LLM_MODEL,
|
||||
"messages": [{"role": "user", "content": prompt}],
|
||||
@@ -39,7 +39,7 @@ def call_llm(current_spec, doc_text):
|
||||
json_text = json_text.split("```json")[1].split("```")[0]
|
||||
elif "```" in json_text:
|
||||
json_text = json_text.split("```")[1].split("```")[0]
|
||||
return json.loads(json_text.strip())
|
||||
return json.loads(json_text.strip()), prompt_id
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
@@ -215,7 +215,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"error": error[0], "time_s": elapsed})
|
||||
continue
|
||||
|
||||
llm_result = result[0]
|
||||
llm_result, prompt_id = result[0]
|
||||
ops = llm_result.get("ops", [])
|
||||
mode = llm_result.get("mode", "partial")
|
||||
|
||||
@@ -237,7 +237,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
# Применить
|
||||
apply_resp = httpx.post(
|
||||
f"{LUCEE_URL}/apply_events.cfm?contract_id={cid}&mode={mode}",
|
||||
json={"supplement_id": sid, "ops": ops}, timeout=30
|
||||
json={"supplement_id": sid, "ops": ops, "prompt_id": prompt_id}, timeout=30
|
||||
)
|
||||
if apply_resp.status_code == 200:
|
||||
ar = apply_resp.json()
|
||||
@@ -258,7 +258,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
body = json.loads(self.rfile.read(length))
|
||||
try:
|
||||
result = call_llm(body.get("current_spec", []), body.get("doc_text", ""))
|
||||
result, prompt_id = call_llm(body.get("current_spec", []), body.get("doc_text", ""))
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.end_headers()
|
||||
|
||||
Reference in New Issue
Block a user