Teotonix commited on
Commit
4c498b9
·
verified ·
1 Parent(s): e9a2dab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -9,26 +9,24 @@ client = OpenAI(
9
  api_key=HF_TOKEN,
10
  )
11
 
12
- # Ücretsiz/hafif model (hf-inference)
13
- MODEL_ID = "TinyLlama/TinyLlama-1.1B-Chat-v1.0:hf-inference"
14
 
15
- SYSTEM = "Sen MAIND AI'sin. Kısa, net ve yardımcı cevap ver."
16
 
17
  def llm_reply(user_text: str) -> str:
18
- resp = client.chat.completions.create(
19
  model=MODEL_ID,
20
  messages=[
21
  {"role": "system", "content": SYSTEM},
22
  {"role": "user", "content": user_text},
23
  ],
24
  temperature=0.7,
25
- max_tokens=256,
26
  )
27
- return resp.choices[0].message.content or ""
28
 
29
  def chat_fn(message, history):
30
- if history is None:
31
- history = []
32
  history.append({"role": "user", "content": message})
33
 
34
  try:
@@ -40,10 +38,8 @@ def chat_fn(message, history):
40
  return history
41
 
42
  with gr.Blocks(title="MaindAI") as demo:
43
- # LOGO (dosya adı repo kökünde: logo.png)
44
- gr.Image("logo.png", show_label=False, height=120)
45
-
46
- gr.Markdown("## 💙 MaindAI — Chat")
47
 
48
  chatbot = gr.Chatbot(value=[])
49
  msg = gr.Textbox(placeholder="Sor...", show_label=False)
 
9
  api_key=HF_TOKEN,
10
  )
11
 
12
+ MODEL_ID = "HuggingFaceH4/zephyr-7b-beta:hf-inference"
 
13
 
14
+ SYSTEM = "Sen MAIND AI'sin. Kısa ve net cevap ver."
15
 
16
  def llm_reply(user_text: str) -> str:
17
+ response = client.chat.completions.create(
18
  model=MODEL_ID,
19
  messages=[
20
  {"role": "system", "content": SYSTEM},
21
  {"role": "user", "content": user_text},
22
  ],
23
  temperature=0.7,
24
+ max_tokens=300,
25
  )
26
+ return response.choices[0].message.content
27
 
28
  def chat_fn(message, history):
29
+ history = history or []
 
30
  history.append({"role": "user", "content": message})
31
 
32
  try:
 
38
  return history
39
 
40
  with gr.Blocks(title="MaindAI") as demo:
41
+ gr.Image("logo.png", height=120, show_label=False)
42
+ gr.Markdown("## 💙 MaindAI")
 
 
43
 
44
  chatbot = gr.Chatbot(value=[])
45
  msg = gr.Textbox(placeholder="Sor...", show_label=False)