Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
+
|
4 |
+
client = InferenceClient(model="http://127.0.0.1:8080")
|
5 |
+
|
6 |
+
def inference(message, history):
|
7 |
+
partial_message = ""
|
8 |
+
for token in client.text_generation(message, max_new_tokens=20, stream=True):
|
9 |
+
partial_message += token
|
10 |
+
yield partial_message
|
11 |
+
|
12 |
+
gr.ChatInterface(
|
13 |
+
inference,
|
14 |
+
chatbot=gr.Chatbot(height=300),
|
15 |
+
textbox=gr.Textbox(placeholder="Chat with me!", container=False, scale=7),
|
16 |
+
description="This is the demo for Gradio UI consuming TGI endpoint with LLaMA 7B-Chat model.",
|
17 |
+
title="Gradio 🤝 TGI",
|
18 |
+
examples=["Are tomatoes vegetables?"],
|
19 |
+
retry_btn="Retry",
|
20 |
+
undo_btn="Undo",
|
21 |
+
clear_btn="Clear",
|
22 |
+
).queue().launch()
|