Spaces:
Running
Running
# | |
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() | |