Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import asyncio | |
| from codeinterpreterapi import File | |
| from frontend.utils import get_images | |
| def code_interpreter_app(input_text, uploaded_file=None): | |
| if uploaded_file is not None: | |
| bytes_data = uploaded_file.read() | |
| uploaded_file_data = File(name=uploaded_file.name, content=bytes_data) | |
| output = asyncio.run(get_images( | |
| input_text, files=[uploaded_file_data])) | |
| else: | |
| # Call get_images without files | |
| output = asyncio.run(get_images(input_text)) | |
| return output | |
| # This will create a textbox where you can input text | |
| input_text = gr.Textbox("Write your prompt") | |
| # This will create a file uploader | |
| file_uploader = gr.File(label="Upload your file", optional=True) | |
| # Interface for the Gradio app | |
| interface = gr.Interface( | |
| fn=code_interpreter_app, | |
| inputs=[input_text, file_uploader], | |
| outputs=gr.Textbox("Output will be shown here"), # Dummy output | |
| title="Code Interpreter API 🚀", | |
| description="给勇哥哥打call 🚀", | |
| ) | |
| interface.launch() | |