Update app.py
Browse files
app.py
CHANGED
@@ -405,7 +405,7 @@ def process_message(messages):
|
|
405 |
html_output += '</div>' # 关闭最外层div
|
406 |
return html_output
|
407 |
|
408 |
-
def
|
409 |
print("done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
410 |
# 初始化组件
|
411 |
# client = AzureOpenAI(
|
@@ -457,7 +457,7 @@ def create_demo():
|
|
457 |
value="gpt-4.1"
|
458 |
)
|
459 |
client_type = gr.Dropdown(label="Client Type Selection", choices=["Azure", "OpenAI"], value="Azure")
|
460 |
-
api_key = gr.Textbox(label="
|
461 |
base_url = gr.Textbox(label="Base URL (optional)", value=os.getenv("AZURE_OPENAI_ENDPOINT"))
|
462 |
image_input = gr.Image(label="Upload Image", type="pil")
|
463 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
@@ -482,8 +482,8 @@ def create_demo():
|
|
482 |
current_json = gr.State(None)
|
483 |
|
484 |
# 处理提交
|
485 |
-
def handle_submit(model, key, url, q, img):
|
486 |
-
html, images, json_data =
|
487 |
return html, images, json_data, images, json_data
|
488 |
|
489 |
submit_btn.click(
|
|
|
405 |
html_output += '</div>' # 关闭最外层div
|
406 |
return html_output
|
407 |
|
408 |
+
def pyvision_chat(model_name, client_type, api_key, base_url, question, image):
|
409 |
print("done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
410 |
# 初始化组件
|
411 |
# client = AzureOpenAI(
|
|
|
457 |
value="gpt-4.1"
|
458 |
)
|
459 |
client_type = gr.Dropdown(label="Client Type Selection", choices=["Azure", "OpenAI"], value="Azure")
|
460 |
+
api_key = gr.Textbox(label="API Key (optional)", type="password", value=os.getenv("AZURE_OPENAI_API_KEY"))
|
461 |
base_url = gr.Textbox(label="Base URL (optional)", value=os.getenv("AZURE_OPENAI_ENDPOINT"))
|
462 |
image_input = gr.Image(label="Upload Image", type="pil")
|
463 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
|
|
482 |
current_json = gr.State(None)
|
483 |
|
484 |
# 处理提交
|
485 |
+
def handle_submit(model, client_type, key, url, q, img):
|
486 |
+
html, images, json_data = pyvision_chat(model, client_type, key, url, q, img)
|
487 |
return html, images, json_data, images, json_data
|
488 |
|
489 |
submit_btn.click(
|