Spaces:
Sleeping
Sleeping
debug
Browse files- app.py +12 -8
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
8 |
)
|
9 |
|
10 |
|
@@ -21,13 +22,16 @@ def respond(
|
|
21 |
messages.append({"role": "question", "content": 질문})
|
22 |
response = ""
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
stream=True,
|
|
|
28 |
temperature=temperature,
|
29 |
top_p=top_p,
|
30 |
-
)
|
|
|
|
|
31 |
token = message.choices[0].delta.content
|
32 |
|
33 |
response += token
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from openai import OpenAI
|
4 |
|
5 |
+
|
6 |
+
client = OpenAI(
|
7 |
+
base_url="https://ueecxhqta9umllae.us-east-1.aws.endpoints.huggingface.cloud/v1/",
|
8 |
+
api_key=os.environ.get("hf_token"),
|
9 |
)
|
10 |
|
11 |
|
|
|
22 |
messages.append({"role": "question", "content": 질문})
|
23 |
response = ""
|
24 |
|
25 |
+
chat_completion = client.chat.completions.create(
|
26 |
+
model="tgi",
|
27 |
+
messages=messages,
|
28 |
stream=True,
|
29 |
+
max_tokens=max_tokens,
|
30 |
temperature=temperature,
|
31 |
top_p=top_p,
|
32 |
+
)
|
33 |
+
|
34 |
+
for message in chat_completion:
|
35 |
token = message.choices[0].delta.content
|
36 |
|
37 |
response += token
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
huggingface_hub==0.22.2
|
|
|
|
1 |
huggingface_hub==0.22.2
|
2 |
+
openai
|