Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,482 Bytes
d31a703 f4cccb0 f219113 f4cccb0 f219113 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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() |