Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ models = {
|
|
18 |
def get_client(model):
|
19 |
return InferenceClient(model=model, token=hf_token)
|
20 |
|
21 |
-
# 응답 생성 함수
|
22 |
def respond(prompt, system_message, max_tokens, temperature, top_p, selected_model):
|
23 |
stop_event.clear()
|
24 |
client = get_client(selected_model)
|
@@ -44,11 +44,10 @@ def respond(prompt, system_message, max_tokens, temperature, top_p, selected_mod
|
|
44 |
break
|
45 |
if chunk:
|
46 |
response += chunk
|
47 |
-
|
48 |
-
return [(prompt, response)] # 대화창에 프롬프트와 응답을 표시
|
49 |
|
50 |
except Exception as e:
|
51 |
-
|
52 |
|
53 |
# 응답 중단 함수
|
54 |
def stop_generation():
|
@@ -62,7 +61,7 @@ with gr.Blocks() as demo:
|
|
62 |
**주의사항:**
|
63 |
- '전송' 버튼을 클릭하거나 입력 필드에서 Shift+Enter를 눌러 메시지를 전송할 수 있습니다.
|
64 |
- Enter 키는 줄바꿈으로 작동합니다.
|
65 |
-
- 입력한 내용에 대해서만 응답하도록 설정되어
|
66 |
""")
|
67 |
|
68 |
with gr.Row():
|
@@ -74,7 +73,7 @@ with gr.Blocks() as demo:
|
|
74 |
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.90, step=0.05, label="Top-p (핵 샘플링)")
|
75 |
|
76 |
system_message = gr.Textbox(
|
77 |
-
value="너는 나의 최고의 비서이다.\n내가
|
78 |
label="시스템 메시지",
|
79 |
lines=5
|
80 |
)
|
|
|
18 |
def get_client(model):
|
19 |
return InferenceClient(model=model, token=hf_token)
|
20 |
|
21 |
+
# 응답 생성 함수 (스트리밍 방식, 자문자답 방지)
|
22 |
def respond(prompt, system_message, max_tokens, temperature, top_p, selected_model):
|
23 |
stop_event.clear()
|
24 |
client = get_client(selected_model)
|
|
|
44 |
break
|
45 |
if chunk:
|
46 |
response += chunk
|
47 |
+
yield [(prompt, response.strip())] # 실시간으로 부분적인 응답 반환
|
|
|
48 |
|
49 |
except Exception as e:
|
50 |
+
yield [(prompt, f"오류 발생: {str(e)}")]
|
51 |
|
52 |
# 응답 중단 함수
|
53 |
def stop_generation():
|
|
|
61 |
**주의사항:**
|
62 |
- '전송' 버튼을 클릭하거나 입력 필드에서 Shift+Enter를 눌러 메시지를 전송할 수 있습니다.
|
63 |
- Enter 키는 줄바꿈으로 작동합니다.
|
64 |
+
- 입력한 내용에 대해서만 응답하도록 설정되어 있으며, 모델이 추가 질문을 만들거나 입력을 확장하지 않도록 설정됩니다.
|
65 |
""")
|
66 |
|
67 |
with gr.Row():
|
|
|
73 |
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.90, step=0.05, label="Top-p (핵 샘플링)")
|
74 |
|
75 |
system_message = gr.Textbox(
|
76 |
+
value="너는 나의 최고의 비서이다.\n내가 요구하는 것들에 대해 정확하고 간결하게 답변하라.\n반드시 한글로 답변할 것.\n사용자의 입력 내용에만 직접적으로 답변하고, 추가 질문을 만들거나 입력을 확장하지 마라.",
|
77 |
label="시스템 메시지",
|
78 |
lines=5
|
79 |
)
|