File size: 984 Bytes
e62ffb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
import gradio as gr

# Define a function to process the selected file and input text
def process_file_and_text(file_path, input_text):
    # Perform some operation using the file path and input text
    with open(file_path, 'r') as file:
        file_content = file.read()
    
    # Combine the file content and input text
    result = f"File Content:\n{file_content}\n\nInput Text:\n{input_text}"
    
    return result

# Create Gradio components for file dropdown, input text box, and output text box
file_dropdown = gr.inputs.File(label="Select a file")
input_text = gr.inputs.Textbox(label="Enter some text")
output_text = gr.outputs.Textbox(label="Processed Result")

# Define the Gradio interface
demo = gr.Interface(
    fn=process_file_and_text,
    inputs=[file_dropdown, input_text],
    outputs=output_text,
    title="File Dropdown with Input Text Demo",
    description="Select a file, enter text, and view the processed result"
)

# Launch the Gradio app
demo.launch()