Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
def chat_with_llama(prompt):
|
| 5 |
+
response = requests.post("http://localhost:8000/completion", json={"prompt": prompt, "max_tokens": 100})
|
| 6 |
+
return response.json().get("text", "Không có phản hồi từ server.")
|
| 7 |
+
|
| 8 |
+
iface = gr.Interface(
|
| 9 |
+
fn=chat_with_llama,
|
| 10 |
+
inputs="text",
|
| 11 |
+
outputs="text",
|
| 12 |
+
title="LLaMA Chatbot trên Hugging Face Space"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|