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,14 @@ 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:
|
@@ -42,11 +51,18 @@ with gr.Blocks() as demo:
|
|
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=[output])
|
|
|
|
|
|
|
51 |
|
52 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
import os
|
4 |
+
import pandas as pd # 엑셀 파일 처리를 위한 pandas 라이브러리 추가
|
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 |
+
# 엑셀 파일을 처리하는 함수 추가
|
33 |
+
def process_excel(file):
|
34 |
+
if file is not None:
|
35 |
+
df = pd.read_excel(file.name) # 엑셀 파일을 읽음
|
36 |
+
return df.head().to_string() # 엑셀 파일의 처음 몇 줄을 출력
|
37 |
+
else:
|
38 |
+
return "엑셀 파일이 업로드되지 않았습니다."
|
39 |
+
|
40 |
title = "AI 텍스트 생성기"
|
41 |
|
42 |
with gr.Blocks() as demo:
|
|
|
51 |
temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.75, step=0.05)
|
52 |
top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
53 |
|
54 |
+
# 엑셀 파일 업로드 컴포넌트 추가
|
55 |
+
excel_file = gr.File(label="엑셀 파일 업로드", type="file")
|
56 |
+
excel_output = gr.Textbox(label="엑셀 내용", lines=10)
|
57 |
+
|
58 |
generate_btn = gr.Button("텍스트 생성하기")
|
59 |
output = gr.Textbox(label="생성된 텍스트", lines=10)
|
60 |
|
61 |
generate_btn.click(fn=generate_text,
|
62 |
inputs=[model, user_message, system_message, max_tokens, temperature, top_p],
|
63 |
outputs=[output])
|
64 |
+
|
65 |
+
# 엑셀 파일 업로드 버튼과 처리 함수 연결
|
66 |
+
excel_file.upload(fn=process_excel, inputs=[excel_file], outputs=[excel_output])
|
67 |
|
68 |
+
demo.launch()
|