Kadoblam commited on
Commit
8c2b443
·
1 Parent(s): afdf5fc

Atualiza app.py para usar modelo Qwen-4B-Instruct

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -14,6 +14,15 @@ client = OpenAI(
14
  class Query(BaseModel):
15
  question: str
16
 
 
 
 
 
 
 
 
 
 
17
  @app.get("/")
18
  async def root():
19
  return {"message": "API está rodando!"}
@@ -54,4 +63,10 @@ async def ask_model(query: Query):
54
  max_tokens=250
55
  )
56
  answer = completion.choices[0].message.content.strip()
 
 
 
 
 
 
57
  return {"answer": answer}
 
14
  class Query(BaseModel):
15
  question: str
16
 
17
+ # Exemplo fixo de caracteres japoneses com romaji para garantir na resposta
18
+ EXEMPLO_JAPONES = """
19
+ Aqui estão alguns caracteres japoneses e seus sons:
20
+
21
+ Hiragana: あ (a), い (i), う (u), え (e), お (o)
22
+ Katakana: ア (a), イ (i), ウ (u), エ (e), オ (o)
23
+ Kanji: 日 (nichi - dia), 本 (hon - livro), 人 (jin - pessoa)
24
+ """
25
+
26
  @app.get("/")
27
  async def root():
28
  return {"message": "API está rodando!"}
 
63
  max_tokens=250
64
  )
65
  answer = completion.choices[0].message.content.strip()
66
+
67
+ # Se a pergunta for sobre japonês, acrescente o exemplo fixo
68
+ texto_pergunta = query.question.lower()
69
+ if "japon" in texto_pergunta or "kanji" in texto_pergunta or "hiragana" in texto_pergunta or "katakana" in texto_pergunta or "caractere" in texto_pergunta:
70
+ answer += "\n\n" + EXEMPLO_JAPONES.strip()
71
+
72
  return {"answer": answer}