Kadoblam
commited on
Commit
·
dfd08bc
1
Parent(s):
8eea636
Atualiza app.py para usar modelo Qwen-4B-Instruct
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from openai import OpenAI
|
| 5 |
-
import langdetect
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
@@ -27,24 +27,25 @@ async def ask_model(query: Query):
|
|
| 27 |
|
| 28 |
if idioma == "pt":
|
| 29 |
system_prompt = (
|
| 30 |
-
"
|
| 31 |
-
"
|
| 32 |
-
"
|
| 33 |
-
"
|
| 34 |
-
"
|
|
|
|
| 35 |
)
|
| 36 |
elif idioma == "en":
|
| 37 |
system_prompt = (
|
| 38 |
-
"
|
| 39 |
-
"
|
| 40 |
-
"
|
| 41 |
-
"
|
| 42 |
-
"
|
|
|
|
| 43 |
)
|
| 44 |
else:
|
| 45 |
system_prompt = (
|
| 46 |
-
"Responda no mesmo idioma da pergunta, de forma direta e curta, "
|
| 47 |
-
"sem usar formatação Markdown."
|
| 48 |
)
|
| 49 |
|
| 50 |
completion = client.chat.completions.create(
|
|
@@ -57,6 +58,4 @@ async def ask_model(query: Query):
|
|
| 57 |
)
|
| 58 |
answer = completion.choices[0].message.content.strip()
|
| 59 |
|
| 60 |
-
# Não adiciona exemplo fixo dos caracteres japoneses para evitar "poluir" a resposta
|
| 61 |
-
|
| 62 |
return {"answer": answer}
|
|
|
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from openai import OpenAI
|
| 5 |
+
import langdetect
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
|
|
| 27 |
|
| 28 |
if idioma == "pt":
|
| 29 |
system_prompt = (
|
| 30 |
+
"Você é um assistente que responde sempre em texto puro, SEM formatação Markdown, SEM asteriscos, SEM negrito, SEM itálico, SEM listas, SEM códigos.\n\n"
|
| 31 |
+
"Quando responder em japonês, escreva sempre os caracteres japoneses reais (kanji, hiragana e katakana) e, logo após, entre parênteses, a transliteração romaji.\n\n"
|
| 32 |
+
"Não substitua os caracteres japoneses por espaços, asteriscos ou quaisquer símbolos. Use sempre os caracteres reais e mantenha a resposta em texto simples.\n\n"
|
| 33 |
+
"Exemplo de resposta correta:\n\n"
|
| 34 |
+
"こんにちは (Konnichiwa) significa \"Olá\".\n\n"
|
| 35 |
+
"Responda brevemente e de forma direta."
|
| 36 |
)
|
| 37 |
elif idioma == "en":
|
| 38 |
system_prompt = (
|
| 39 |
+
"You are an assistant that always responds in plain text, WITHOUT Markdown formatting, WITHOUT asterisks, bold, italics, lists, or code.\n\n"
|
| 40 |
+
"When responding in Japanese, always write the real Japanese characters (kanji, hiragana, and katakana) followed immediately by the romaji transliteration in parentheses.\n\n"
|
| 41 |
+
"Do not replace Japanese characters with spaces, asterisks, or any symbols. Always use the real characters and keep the response in plain text.\n\n"
|
| 42 |
+
"Example of correct response:\n\n"
|
| 43 |
+
"こんにちは (Konnichiwa) means \"Hello\".\n\n"
|
| 44 |
+
"Respond briefly and directly."
|
| 45 |
)
|
| 46 |
else:
|
| 47 |
system_prompt = (
|
| 48 |
+
"Responda no mesmo idioma da pergunta, de forma direta e curta, sem formatação Markdown."
|
|
|
|
| 49 |
)
|
| 50 |
|
| 51 |
completion = client.chat.completions.create(
|
|
|
|
| 58 |
)
|
| 59 |
answer = completion.choices[0].message.content.strip()
|
| 60 |
|
|
|
|
|
|
|
| 61 |
return {"answer": answer}
|