Spaces:
Running
on
Zero
Running
on
Zero
import gradio as gr | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
from embodied_gen.utils.gpt_clients import GPT_CLIENT | |
print(GPT_CLIENT.api_version, GPT_CLIENT.model_name, GPT_CLIENT.endpoint) | |
def debug_gptclient(text_prompt, images, system_role): | |
try: | |
# Handle image input (Gradio passes images as PIL.Image or file paths) | |
image_base64 = images if images else None | |
response = GPT_CLIENT.query( | |
text_prompt=text_prompt, | |
image_base64=image_base64, | |
system_role=system_role | |
) | |
return response if response else "No response received or an error occurred." | |
except Exception as e: | |
return f"Error: {str(e)}" | |
# Create Gradio interface | |
iface = gr.Interface( | |
fn=debug_gptclient, | |
inputs=[ | |
gr.Textbox(label="Text Prompt", placeholder="Enter your text prompt here"), | |
gr.File(label="Images (Optional)", type="filepath", file_count="multiple"), | |
gr.Textbox( | |
label="System Role (Optional)", | |
placeholder="Enter system role or leave empty for default", | |
value="You are a highly knowledgeable assistant specializing in physics, engineering, and object properties." | |
) | |
], | |
outputs=gr.Textbox(label="Response"), | |
title="GPTclient Debug Interface", | |
description="A simple interface to debug GPTclient inputs and outputs." | |
) | |
if __name__ == "__main__": | |
iface.launch() |