Spaces:
Paused
Paused
Update app.py
Browse files在Gradio的更新版本中,inputs和outputs属性已经被废弃,取而代之的是直接使用组件类来定义输入和输出。这个是更新后的代码
app.py
CHANGED
@@ -34,16 +34,17 @@ def analyze_document(file, prompt):
|
|
34 |
return response
|
35 |
|
36 |
# Define Gradio interface
|
|
|
|
|
|
|
|
|
37 |
iface = gr.Interface(
|
38 |
fn=analyze_document,
|
39 |
-
inputs=[
|
40 |
-
|
41 |
-
gr.inputs.Textbox(label="Prompt", placeholder="Enter your structured prompt here")
|
42 |
-
],
|
43 |
-
outputs="text",
|
44 |
title="Document Analysis with GPT Model",
|
45 |
description="Upload a TXT or PDF document and enter a prompt to get an analysis."
|
46 |
)
|
47 |
|
48 |
# Launch the interface
|
49 |
-
iface.launch()
|
|
|
34 |
return response
|
35 |
|
36 |
# Define Gradio interface
|
37 |
+
file_input = gr.File(label="Upload TXT or PDF Document", file_count="single")
|
38 |
+
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your structured prompt here")
|
39 |
+
output_text = gr.Textbox(label="Analysis Result")
|
40 |
+
|
41 |
iface = gr.Interface(
|
42 |
fn=analyze_document,
|
43 |
+
inputs=[file_input, prompt_input],
|
44 |
+
outputs=output_text,
|
|
|
|
|
|
|
45 |
title="Document Analysis with GPT Model",
|
46 |
description="Upload a TXT or PDF document and enter a prompt to get an analysis."
|
47 |
)
|
48 |
|
49 |
# Launch the interface
|
50 |
+
iface.launch()
|