Update app.py
Browse files
app.py
CHANGED
|
@@ -9,26 +9,24 @@ client = OpenAI(
|
|
| 9 |
api_key=HF_TOKEN,
|
| 10 |
)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
MODEL_ID = "TinyLlama/TinyLlama-1.1B-Chat-v1.0:hf-inference"
|
| 14 |
|
| 15 |
-
SYSTEM = "Sen MAIND AI'sin. Kısa
|
| 16 |
|
| 17 |
def llm_reply(user_text: str) -> str:
|
| 18 |
-
|
| 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=
|
| 26 |
)
|
| 27 |
-
return
|
| 28 |
|
| 29 |
def chat_fn(message, history):
|
| 30 |
-
|
| 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 |
-
|
| 44 |
-
gr.
|
| 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)
|