change: prompting, fix: citations
This commit is contained in:
+14
-10
@@ -740,7 +740,7 @@ class SXNGPlugin(Plugin):
|
|||||||
target_words = int(self.max_tokens * 0.4)
|
target_words = int(self.max_tokens * 0.4)
|
||||||
lang_instruction = f" Respond in {lang}." if lang not in ('all', 'auto') else ""
|
lang_instruction = f" Respond in {lang}." if lang not in ('all', 'auto') else ""
|
||||||
|
|
||||||
SYSTEM = f"You are a direct, citation-accurate search assistant. Today is {today}.{lang_instruction}"
|
SYSTEM = f"You are a direct, citation-accurate search synthesis engine and assistant. Today is {today}.{lang_instruction}"
|
||||||
max_source_idx = 0
|
max_source_idx = 0
|
||||||
if context_text:
|
if context_text:
|
||||||
indices = re.findall(r'\[(\d+)\]', context_text)
|
indices = re.findall(r'\[(\d+)\]', context_text)
|
||||||
@@ -748,11 +748,11 @@ class SXNGPlugin(Plugin):
|
|||||||
max_source_idx = max(map(int, indices))
|
max_source_idx = max(map(int, indices))
|
||||||
|
|
||||||
CORE_RULES = [
|
CORE_RULES = [
|
||||||
"1. Answer the question directly using ONLY the provided context.",
|
"Answer the question directly using ONLY the provided context.",
|
||||||
f"2. High density (80%+): Expert-briefing level. Aim for ~{target_words} words.",
|
f"High density: Expert-briefing level. Aim for ~{target_words} words.",
|
||||||
"2. Cite facts using [1], [2], etc. If using general knowledge, cite [*].",
|
"CITATIONS: Cite format is [n] for facts from grounding sources or if using general knowledge, cite [*].",
|
||||||
"3. Do not use filler words, transitions, or meta-commentary.",
|
"Do not use filler words, transitions, or meta-commentary.",
|
||||||
"4. Never explain your process. Just provide the facts.",
|
"Never explain your process. Just provide the facts.",
|
||||||
]
|
]
|
||||||
|
|
||||||
if q == "Continue":
|
if q == "Continue":
|
||||||
@@ -802,7 +802,9 @@ class SXNGPlugin(Plugin):
|
|||||||
res = conn.getresponse()
|
res = conn.getresponse()
|
||||||
|
|
||||||
if res.status != 200:
|
if res.status != 200:
|
||||||
logger.error(f"{PLUGIN_NAME}: Gemini API {res.status}")
|
body = res.read(2048).decode('utf-8', errors='replace')[:500]
|
||||||
|
logger.error(f"{PLUGIN_NAME}: Gemini API {res.status}: {body}")
|
||||||
|
yield f"\n⚠️ API error {res.status}. Check server logs.\n"
|
||||||
return
|
return
|
||||||
|
|
||||||
decoder = json.JSONDecoder()
|
decoder = json.JSONDecoder()
|
||||||
@@ -857,7 +859,9 @@ class SXNGPlugin(Plugin):
|
|||||||
res = conn.getresponse()
|
res = conn.getresponse()
|
||||||
|
|
||||||
if res.status != 200:
|
if res.status != 200:
|
||||||
logger.error(f"{PLUGIN_NAME}: {self.provider} API {res.status}")
|
body = res.read(2048).decode('utf-8', errors='replace')[:500]
|
||||||
|
logger.error(f"{PLUGIN_NAME}: {self.provider} API {res.status}: {body}")
|
||||||
|
yield f"\n⚠️ API error {res.status}. Check server logs.\n"
|
||||||
return
|
return
|
||||||
|
|
||||||
decoder = json.JSONDecoder()
|
decoder = json.JSONDecoder()
|
||||||
@@ -1248,12 +1252,12 @@ class SXNGPlugin(Plugin):
|
|||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if (!started) {{
|
if (!started && !collectedResponse.trim()) {{
|
||||||
const cursor = data.querySelector('.sxng-cursor');
|
const cursor = data.querySelector('.sxng-cursor');
|
||||||
if (cursor) cursor.remove();
|
if (cursor) cursor.remove();
|
||||||
const errSpan = document.createElement('span');
|
const errSpan = document.createElement('span');
|
||||||
errSpan.style.color = '#bf616a';
|
errSpan.style.color = '#bf616a';
|
||||||
errSpan.textContent = 'No response received. Check API configuration.';
|
errSpan.textContent = 'No response received. Check API configuration and server logs.';
|
||||||
data.appendChild(errSpan);
|
data.appendChild(errSpan);
|
||||||
return;
|
return;
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user