Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,21 +88,66 @@ with gr.Blocks() as demo:
|
|
| 88 |
model_radio = gr.Radio(choices=list(MODELS.keys()), value="Zephyr 7B Beta", label="언어 모델 선택")
|
| 89 |
prompt_input = gr.Textbox(label="프롬프트 입력", lines=5)
|
| 90 |
reference_text_input = gr.Textbox(label="참고 텍스트 입력", lines=5)
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
with gr.Row():
|
| 93 |
max_tokens_slider = gr.Slider(minimum=0, maximum=5000, value=2000, step=100, label="최대 토큰 수")
|
| 94 |
temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.75, step=0.05, label="온도")
|
| 95 |
top_p_slider = gr.Slider(minimum=0, maximum=1, value=0.95, step=0.05, label="Top P")
|
| 96 |
-
|
| 97 |
generate_button = gr.Button("응답 생성")
|
|
|
|
| 98 |
response_output = gr.HTML(label="생성된 응답")
|
| 99 |
|
| 100 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
generate_button.click(
|
| 102 |
generate_response,
|
| 103 |
inputs=[prompt_input, reference_text_input, max_tokens_slider, temperature_slider, top_p_slider, model_radio],
|
| 104 |
outputs=response_output
|
| 105 |
)
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
# 인터페이스 실행
|
| 108 |
demo.launch(share=True)
|
|
|
|
| 88 |
model_radio = gr.Radio(choices=list(MODELS.keys()), value="Zephyr 7B Beta", label="언어 모델 선택")
|
| 89 |
prompt_input = gr.Textbox(label="프롬프트 입력", lines=5)
|
| 90 |
reference_text_input = gr.Textbox(label="참고 텍스트 입력", lines=5)
|
| 91 |
+
|
| 92 |
+
# 입력창 3개 추가
|
| 93 |
+
input1 = gr.Textbox(label="입력창 1")
|
| 94 |
+
input2 = gr.Textbox(label="입력창 2")
|
| 95 |
+
input3 = gr.Textbox(label="입력창 3")
|
| 96 |
+
|
| 97 |
+
# 파일 업로드 메뉴 (이미지 파일 업로드)
|
| 98 |
+
image_upload = gr.File(label="파일 업로드", file_types=["image"])
|
| 99 |
+
|
| 100 |
+
# 폰트 파일 업로드 메뉴
|
| 101 |
+
font_upload = gr.File(label="폰트 파일 업로드", file_types=["font"])
|
| 102 |
+
|
| 103 |
+
# 업로드한 폰트를 선택할 수 있는 드롭다운 메뉴
|
| 104 |
+
font_dropdown = gr.Dropdown(label="폰트 선택", choices=[])
|
| 105 |
+
|
| 106 |
+
# 출력창 2개 추가
|
| 107 |
+
output1 = gr.Textbox(label="출력창 1")
|
| 108 |
+
output2 = gr.Textbox(label="출력창 2")
|
| 109 |
+
|
| 110 |
with gr.Row():
|
| 111 |
max_tokens_slider = gr.Slider(minimum=0, maximum=5000, value=2000, step=100, label="최대 토큰 수")
|
| 112 |
temperature_slider = gr.Slider(minimum=0, maximum=1, value=0.75, step=0.05, label="온도")
|
| 113 |
top_p_slider = gr.Slider(minimum=0, maximum=1, value=0.95, step=0.05, label="Top P")
|
| 114 |
+
|
| 115 |
generate_button = gr.Button("응답 생성")
|
| 116 |
+
run_button = gr.Button("실행") # 실행 버튼 생성
|
| 117 |
response_output = gr.HTML(label="생성된 응답")
|
| 118 |
|
| 119 |
+
# 폰트 파일 업로드 시 드롭다운 메뉴 업데이트 함수
|
| 120 |
+
def update_font_list(font_file):
|
| 121 |
+
if font_file is not None:
|
| 122 |
+
font_name = os.path.basename(font_file.name)
|
| 123 |
+
current_fonts = font_dropdown.choices or []
|
| 124 |
+
if font_name not in current_fonts:
|
| 125 |
+
updated_fonts = current_fonts + [font_name]
|
| 126 |
+
return gr.Dropdown.update(choices=updated_fonts)
|
| 127 |
+
return gr.Dropdown.update()
|
| 128 |
+
|
| 129 |
+
# 폰트 파일 업로드 이벤트에 함수 연결
|
| 130 |
+
font_upload.upload(update_font_list, inputs=font_upload, outputs=font_dropdown)
|
| 131 |
+
|
| 132 |
+
# 응답 생성 버튼 클릭 시 함수 실행
|
| 133 |
generate_button.click(
|
| 134 |
generate_response,
|
| 135 |
inputs=[prompt_input, reference_text_input, max_tokens_slider, temperature_slider, top_p_slider, model_radio],
|
| 136 |
outputs=response_output
|
| 137 |
)
|
| 138 |
|
| 139 |
+
# 실행 버튼 클릭 시 동작할 함수 정의
|
| 140 |
+
def run_action(input1_value, input2_value, input3_value):
|
| 141 |
+
output_text1 = f"입력창 1의 내용: {input1_value}"
|
| 142 |
+
output_text2 = f"입력창 2의 내용: {input2_value}"
|
| 143 |
+
return output_text1, output_text2
|
| 144 |
+
|
| 145 |
+
# 실행 버튼 클릭 시 함수 연결
|
| 146 |
+
run_button.click(
|
| 147 |
+
run_action,
|
| 148 |
+
inputs=[input1, input2, input3],
|
| 149 |
+
outputs=[output1, output2]
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
# 인터페이스 실행
|
| 153 |
demo.launch(share=True)
|