feat: switch AI to gpt-oss-120b for fluent Turkish/Kurdish, enforce plain text

llama-3.3-70b's Turkish read like stilted translation ('gostermektedir'
chains). openai/gpt-oss-120b on the same Groq key produces natural,
conversational Turkish (A/B tested on the same prompt). Also: explicit
natural-language + no-markdown style rules in both system prompts, and a
deterministic sanitizer stripping **/# remnants before sending - models
occasionally emit markdown regardless, and Telegram renders it raw.
This commit is contained in:
2026-07-19 09:57:33 -07:00
parent 8e49cbc0db
commit 0102315fab
4 changed files with 15 additions and 6 deletions
+5 -1
View File
@@ -10,6 +10,8 @@ const SYSTEM = `You are the official PezkuwiChain AI Assistant on the news site
RULES:
- Answer in the SAME LANGUAGE the user writes in. If they write in Kurdish (Kurmancî), answer in Kurdish. If Turkish, answer in Turkish. If English, answer in English. If Arabic, answer in Arabic. If Persian, answer in Persian.
- Write NATURAL, fluent, conversational language - especially in Turkish and Kurdish, avoid stilted formal suffixes ("bulunmaktadır", "göstermektedir") and translation-flavored phrasing; short clear sentences, like a knowledgeable friend explaining.
- STRICTLY plain text: never use markdown (**, ##, bullet asterisks). Simple dashes for lists are fine.
- Be concise — website answers should be short, clear and helpful.
- Use plain text, no markdown headers. You can use bold with *text* sparingly.
- If you don't know something, say so honestly.
@@ -258,7 +260,7 @@ serve(async (req) => {
method: 'POST',
headers: { Authorization: 'Bearer ' + GROQ_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'llama-3.3-70b-versatile',
model: 'openai/gpt-oss-120b',
temperature: 0.3,
max_tokens: 900,
messages: [{ role: 'system', content: SYSTEM }, ...messages],
@@ -300,6 +302,8 @@ serve(async (req) => {
if (!answer)
return J({ answer: 'Sorry, I could not answer right now. Please try again.' }, 200);
// Models occasionally emit markdown despite the plain-text rule.
answer = answer.replace(/\*\*/g, '').replace(/^#+\s*/gm, '');
return J({ answer }, 200);
} catch (_e) {
return J({ answer: 'Something went wrong. Please try again.' }, 200);