Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import requests
|
| 3 |
-
|
| 4 |
-
OLLAMA_URL = "http://localhost:11434/api/generate"
|
| 5 |
|
| 6 |
def chat_fn(message, history):
|
| 7 |
if history is None:
|
| 8 |
history = []
|
| 9 |
|
| 10 |
-
history.append({
|
| 11 |
-
|
| 12 |
-
"content": message
|
| 13 |
-
})
|
| 14 |
-
|
| 15 |
-
history.append({
|
| 16 |
-
"role": "assistant",
|
| 17 |
-
"content": f"Test cevap: {message}"
|
| 18 |
-
})
|
| 19 |
|
| 20 |
return history
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
gr.
|
| 26 |
-
|
| 27 |
-
gr.Markdown("## 🧠 Maind.ai Chat")
|
| 28 |
-
|
| 29 |
-
chatbot = gr.Chatbot(height=300)
|
| 30 |
-
msg = gr.Textbox(
|
| 31 |
-
placeholder="Bir şey sor...",
|
| 32 |
-
show_label=False
|
| 33 |
-
)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
send.click(
|
| 38 |
-
chat_fn,
|
| 39 |
-
inputs=[msg, chatbot],
|
| 40 |
-
outputs=[chatbot, msg]
|
| 41 |
-
)
|
| 42 |
-
chatbot = gr.Chatbot(
|
| 43 |
-
label="Maind.ai",
|
| 44 |
-
type="messages"
|
| 45 |
-
)
|
| 46 |
|
| 47 |
demo.launch(
|
| 48 |
server_name="0.0.0.0",
|
| 49 |
-
server_port=7860
|
| 50 |
-
show_error=True
|
| 51 |
)
|
| 52 |
-
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def chat_fn(message, history):
|
| 4 |
if history is None:
|
| 5 |
history = []
|
| 6 |
|
| 7 |
+
history.append({"role": "user", "content": message})
|
| 8 |
+
history.append({"role": "assistant", "content": f"Test cevap: {message}"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
return history
|
| 11 |
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
gr.Markdown("## 🤖 Maind.ai")
|
| 14 |
|
| 15 |
+
chatbot = gr.Chatbot(type="messages")
|
| 16 |
+
msg = gr.Textbox(placeholder="Sor...")
|
| 17 |
+
btn = gr.Button("Gönder")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
btn.click(chat_fn, inputs=[msg, chatbot], outputs=chatbot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
demo.launch(
|
| 22 |
server_name="0.0.0.0",
|
| 23 |
+
server_port=7860
|
|
|
|
| 24 |
)
|
|
|