Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
"""
|
5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
-
"""
|
7 |
-
client = InferenceClient("Hbigscience/bloom")
|
8 |
-
|
9 |
|
10 |
def respond(
|
11 |
message,
|
@@ -14,6 +8,8 @@ def respond(
|
|
14 |
max_tokens,
|
15 |
temperature,
|
16 |
top_p,
|
|
|
|
|
17 |
):
|
18 |
messages = [{"role": "system", "content": system_message}]
|
19 |
|
@@ -39,25 +35,38 @@ def respond(
|
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
demo = gr.ChatInterface(
|
46 |
-
respond,
|
47 |
-
additional_inputs=[
|
48 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
49 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
50 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
51 |
-
gr.Slider(
|
52 |
-
minimum=0.1,
|
53 |
-
maximum=1.0,
|
54 |
-
value=0.95,
|
55 |
-
step=0.05,
|
56 |
-
label="Top-p (nucleus sampling)",
|
57 |
-
),
|
58 |
-
],
|
59 |
-
)
|
60 |
|
|
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def respond(
|
5 |
message,
|
|
|
8 |
max_tokens,
|
9 |
temperature,
|
10 |
top_p,
|
11 |
+
client,
|
12 |
+
prompts_df,
|
13 |
):
|
14 |
messages = [{"role": "system", "content": system_message}]
|
15 |
|
|
|
35 |
response += token
|
36 |
yield response
|
37 |
|
38 |
+
# 데이터셋 업데이트
|
39 |
+
if len(prompts_df) > 0:
|
40 |
+
prompts_df = prompts_df.iloc[1:, :]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
# ...
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
+
# 데이터셋 로드
|
46 |
+
prompts_df = pd.read_csv("prompts.csv")
|
47 |
+
|
48 |
+
# ...
|
49 |
+
|
50 |
+
while True:
|
51 |
+
user_input = input("사용자: ")
|
52 |
+
|
53 |
+
# 데이터셋에서 프롬프트 추출
|
54 |
+
if len(prompts_df) > 0:
|
55 |
+
prompt = prompts_df["prompt"].values[0]
|
56 |
+
prompts_df = prompts_df.iloc[1:, :]
|
57 |
+
else:
|
58 |
+
prompt = None
|
59 |
+
|
60 |
+
# ...
|
61 |
+
|
62 |
+
# 데이터셋 프롬프트 사용
|
63 |
+
if prompt:
|
64 |
+
history.append((user_input, None))
|
65 |
+
user_input = prompt
|
66 |
+
|
67 |
+
# ...
|
68 |
+
|
69 |
+
# 대화 내용 기록
|
70 |
+
history.append((user_input, response))
|
71 |
+
|
72 |
+
# ...
|