Spaces:
Running
Running
File size: 595 Bytes
8414f72 11e4790 8414f72 11e4790 8414f72 11e4790 8414f72 11e4790 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#
import gradio as gr
import pandas as pd
def process_file(file, question):
# 读取文件
if file.name.endswith('.csv'):
df = pd.read_csv(file)
else:
df = pd.read_excel(file)
# 将 DataFrame 转换为字符串
df_string = df.to_string()
# 这里只是输出 DataFrame 字符串和用户问题
# 您可以根据需要添加额外的逻辑
return df_string + "\nQ: " + question
iface = gr.Interface(
fn=process_file,
inputs=[gr.inputs.File(type='file'), gr.inputs.Textbox(label="Your Question")],
outputs="text"
)
iface.launch()
|