Spaces:
Runtime error
Runtime error
MS-YUN
commited on
Commit
ยท
91cba01
1
Parent(s):
8b332f8
Add application file1
Browse files- Dockerfile +20 -0
- app.py +23 -0
- requirements.txt +3 -0
Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://huggingface.co/spaces/msy127/docker_blank_test ๊ฐ์ด๋์ ๋ฐ๋ผ ์์ฑํจ
|
2 |
+
|
3 |
+
|
4 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
5 |
+
# you will also find guides on how best to write your Dockerfile
|
6 |
+
|
7 |
+
FROM python:3.10.6
|
8 |
+
|
9 |
+
WORKDIR /code
|
10 |
+
|
11 |
+
# Matplotlib ํ๊ฒฝ ๋ณ์ ์ค์ (chatgpt ์๋ ค์ค๊ฑฐ)
|
12 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib
|
13 |
+
|
14 |
+
COPY ./requirements.txt /code/requirements.txt
|
15 |
+
|
16 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
17 |
+
|
18 |
+
COPY . .
|
19 |
+
|
20 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
+
|
4 |
+
# client = InferenceClient(model="http://127.0.0.1:8080")
|
5 |
+
client = InferenceClient(model="https://ef15-14-32-200-179.ngrok.io")
|
6 |
+
|
7 |
+
def inference(message, history):
|
8 |
+
partial_message = ""
|
9 |
+
for token in client.text_generation(message, max_new_tokens=256, stream=True):
|
10 |
+
partial_message += token
|
11 |
+
yield partial_message
|
12 |
+
|
13 |
+
gr.ChatInterface(
|
14 |
+
inference,
|
15 |
+
chatbot=gr.Chatbot(height=300),
|
16 |
+
textbox=gr.Textbox(placeholder="Chat with me!", container=False, scale=7),
|
17 |
+
description="This is the demo for Gradio UI consuming TGI endpoint with LLaMA 7B-Chat model.",
|
18 |
+
title="Gradio ๐ค TGI",
|
19 |
+
examples=["Are tomatoes vegetables?"],
|
20 |
+
retry_btn="Retry",
|
21 |
+
undo_btn="Undo",
|
22 |
+
clear_btn="Clear",
|
23 |
+
).queue().launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
uvicorn
|
2 |
+
gradio
|
3 |
+
huggingface_hub
|