Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
import os
|
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
|
6 |
MODELS = {
|
@@ -28,6 +29,10 @@ def call_api(model, content, system_message, max_tokens, temperature, top_p):
|
|
28 |
def generate_text(model, user_message, system_message, max_tokens, temperature, top_p):
|
29 |
return call_api(model, user_message, system_message, max_tokens, temperature, top_p)
|
30 |
|
|
|
|
|
|
|
|
|
31 |
title = "AI 텍스트 생성기"
|
32 |
|
33 |
with gr.Blocks() as demo:
|
@@ -36,17 +41,31 @@ with gr.Blocks() as demo:
|
|
36 |
model = gr.Radio(choices=list(MODELS.keys()), label="언어 모델 선택", value="Zephyr 7B Beta")
|
37 |
user_message = gr.Textbox(label="사용자 메시지", lines=5)
|
38 |
system_message = gr.Textbox(label="시스템 메시지 (프롬프트)", lines=10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
|
|
|
|
|
|
|
40 |
with gr.Accordion("고급 설정", open=False):
|
41 |
max_tokens = gr.Slider(label="Max Tokens", minimum=0, maximum=4000, value=500, step=100)
|
42 |
temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.75, step=0.05)
|
43 |
top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
44 |
|
|
|
45 |
generate_btn = gr.Button("텍스트 생성하기")
|
46 |
-
output = gr.Textbox(label="생성된 텍스트", lines=10)
|
47 |
|
48 |
generate_btn.click(fn=generate_text,
|
49 |
inputs=[model, user_message, system_message, max_tokens, temperature, top_p],
|
50 |
-
outputs=[
|
|
|
|
|
51 |
|
52 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
import os
|
4 |
+
import pandas as pd
|
5 |
from huggingface_hub import InferenceClient
|
6 |
|
7 |
MODELS = {
|
|
|
29 |
def generate_text(model, user_message, system_message, max_tokens, temperature, top_p):
|
30 |
return call_api(model, user_message, system_message, max_tokens, temperature, top_p)
|
31 |
|
32 |
+
def upload_excel(file):
|
33 |
+
df = pd.read_excel(file.name)
|
34 |
+
return df.head().to_string()
|
35 |
+
|
36 |
title = "AI 텍스트 생성기"
|
37 |
|
38 |
with gr.Blocks() as demo:
|
|
|
41 |
model = gr.Radio(choices=list(MODELS.keys()), label="언어 모델 선택", value="Zephyr 7B Beta")
|
42 |
user_message = gr.Textbox(label="사용자 메시지", lines=5)
|
43 |
system_message = gr.Textbox(label="시스템 메시지 (프롬프트)", lines=10)
|
44 |
+
|
45 |
+
# 입력창 2개 추가
|
46 |
+
input1 = gr.Textbox(label="입력창 1")
|
47 |
+
input2 = gr.Textbox(label="입력창 2")
|
48 |
+
|
49 |
+
# 출력창 2개 추가
|
50 |
+
output1 = gr.Textbox(label="출력창 1", lines=10)
|
51 |
+
output2 = gr.Textbox(label="출력창 2", lines=10)
|
52 |
|
53 |
+
# 엑셀 업로드 기능 추가
|
54 |
+
excel_input = gr.File(label="엑셀 파일 업로드", file_types=[".xls", ".xlsx"])
|
55 |
+
excel_output = gr.Textbox(label="엑셀 내용 미리보기", lines=10)
|
56 |
+
|
57 |
with gr.Accordion("고급 설정", open=False):
|
58 |
max_tokens = gr.Slider(label="Max Tokens", minimum=0, maximum=4000, value=500, step=100)
|
59 |
temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.75, step=0.05)
|
60 |
top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
61 |
|
62 |
+
# 실행 버튼 추가
|
63 |
generate_btn = gr.Button("텍스트 생성하기")
|
|
|
64 |
|
65 |
generate_btn.click(fn=generate_text,
|
66 |
inputs=[model, user_message, system_message, max_tokens, temperature, top_p],
|
67 |
+
outputs=[output1, output2])
|
68 |
+
|
69 |
+
excel_input.upload(upload_excel, inputs=[excel_input], outputs=[excel_output])
|
70 |
|
71 |
+
demo.launch()
|