mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-07-24 10:35:41 +00:00
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:
@@ -90,6 +90,8 @@ const CLAUDE_SYSTEM_PROMPT = `You are the official PezkuwiChain AI Assistant on
|
||||
|
||||
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 — Telegram messages should be short and readable.
|
||||
- Use plain text, no markdown headers. You can use bold with *text* sparingly.
|
||||
- If you don't know something, say so honestly.
|
||||
@@ -293,7 +295,7 @@ async function handleAIChat(token: string, chatId: number, userMessage: string,
|
||||
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: [
|
||||
@@ -336,6 +338,9 @@ async function handleAIChat(token: string, chatId: number, userMessage: string,
|
||||
}
|
||||
}
|
||||
|
||||
// Models occasionally emit markdown despite the plain-text rule; Telegram renders it raw.
|
||||
if (aiReply) aiReply = aiReply.replace(/\*\*/g, '').replace(/^#+\s*/gm, '');
|
||||
|
||||
if (!aiReply) {
|
||||
await sendTelegramRequest(token, 'sendMessage', {
|
||||
chat_id: chatId,
|
||||
|
||||
Reference in New Issue
Block a user