stzhao commited on
Commit
feccc43
·
verified ·
1 Parent(s): 4a7a98b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -408,8 +408,6 @@ def process_message(messages):
408
  def o3_chat(model_name, api_key, base_url, question, image):
409
  print("done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
410
  # 初始化组件
411
- # os.environ['AZURE_OPENAI_API_KEY'] = "5890112fd69a4c7e9981f0c87d7f4568"
412
- # os.environ['AZURE_OPENAI_ENDPOINT'] = "https://guohe-apim.azure-api.net"
413
  client = AzureOpenAI(
414
  api_key=os.getenv("AZURE_OPENAI_API_KEY"), # 从环境变量读取
415
  api_version="2025-04-01-preview", # 使用最新API版本
@@ -417,7 +415,6 @@ def o3_chat(model_name, api_key, base_url, question, image):
417
  )
418
  # client = OpenAI(api_key=api_key, base_url=base_url)
419
  executor = PythonExecutor()
420
- # executor = SharedRuntimeExecutor(var_whitelist="RETAIN_ALL_VARS")
421
 
422
  prompt_template = json.load(open("./prompt_template_vis.json", "r", encoding="utf-8"))
423
  prompt_type = 'vistool_with_img_info_v2'
@@ -451,8 +448,8 @@ def create_demo():
451
  choices=["gpt-4.1"],
452
  value="gpt-4.1"
453
  )
454
- api_key = gr.Textbox(label="OpenAI API Key", type="password", value="sk-kBQuM0gvNBhOHmKz43b3iQut01bsOgg8Pv76eMKguu6jvncm")
455
- base_url = gr.Textbox(label="Base URL (optional)", value="https://api.claudeshop.top/v1")
456
  image_input = gr.Image(label="Upload Image", type="pil")
457
  question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
458
  submit_btn = gr.Button("Submit")
@@ -479,13 +476,6 @@ def create_demo():
479
  def handle_submit(model, key, url, q, img):
480
  html, images, json_data = o3_chat(model, key, url, q, img)
481
  return html, images, json_data, images, json_data
482
-
483
- # # 处理提交
484
- # submit_btn.click(
485
- # fn=o3_chat,
486
- # inputs=[model_name, api_key, base_url, question, image_input],
487
- # outputs=[output, extracted_images, extracted_json]
488
- # )
489
 
490
  submit_btn.click(
491
  fn=handle_submit,
@@ -508,10 +498,10 @@ def create_demo():
508
 
509
  # 示例部分
510
  examples = [
511
- [
512
- "./examples/1.png",
513
- "From the information on that advertising board, what is the type of this shop?\nA. The shop is a yoga studio.\nB. The shop is a cafe.\nC. The shop is a seven-eleven.\nD. The shop is a milk tea shop.",
514
- ],
515
  [
516
  "./examples/2.png",
517
  "What is the diagnosis for the abnormality seen in this image?\nA. Pulmonary embolism.\nB. Tuberculosis.\nC. COVID-19 infection.\nD. Influenza.",
@@ -594,7 +584,7 @@ def create_demo():
594
 
595
  gr.Markdown("""
596
  ### Tips
597
- 1. Click the 'log' botton top left to check the output log.
598
  2. It may take 2~5 min.
599
  """)
600
 
 
408
  def o3_chat(model_name, api_key, base_url, question, image):
409
  print("done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
410
  # 初始化组件
 
 
411
  client = AzureOpenAI(
412
  api_key=os.getenv("AZURE_OPENAI_API_KEY"), # 从环境变量读取
413
  api_version="2025-04-01-preview", # 使用最新API版本
 
415
  )
416
  # client = OpenAI(api_key=api_key, base_url=base_url)
417
  executor = PythonExecutor()
 
418
 
419
  prompt_template = json.load(open("./prompt_template_vis.json", "r", encoding="utf-8"))
420
  prompt_type = 'vistool_with_img_info_v2'
 
448
  choices=["gpt-4.1"],
449
  value="gpt-4.1"
450
  )
451
+ # api_key = gr.Textbox(label="OpenAI API Key", type="password", value="sk-kBQuM0gvNBhOHmKz43b3iQut01bsOgg8Pv76eMKguu6jvncm")
452
+ # base_url = gr.Textbox(label="Base URL (optional)", value="https://api.claudeshop.top/v1")
453
  image_input = gr.Image(label="Upload Image", type="pil")
454
  question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
455
  submit_btn = gr.Button("Submit")
 
476
  def handle_submit(model, key, url, q, img):
477
  html, images, json_data = o3_chat(model, key, url, q, img)
478
  return html, images, json_data, images, json_data
 
 
 
 
 
 
 
479
 
480
  submit_btn.click(
481
  fn=handle_submit,
 
498
 
499
  # 示例部分
500
  examples = [
501
+ # [
502
+ # "./examples/1.png",
503
+ # "From the information on that advertising board, what is the type of this shop?\nA. The shop is a yoga studio.\nB. The shop is a cafe.\nC. The shop is a seven-eleven.\nD. The shop is a milk tea shop.",
504
+ # ],
505
  [
506
  "./examples/2.png",
507
  "What is the diagnosis for the abnormality seen in this image?\nA. Pulmonary embolism.\nB. Tuberculosis.\nC. COVID-19 infection.\nD. Influenza.",
 
584
 
585
  gr.Markdown("""
586
  ### Tips
587
+ 1. We have set the API in this space, but if you want try run this demo on more data, please duplicate this space and set your own API.
588
  2. It may take 2~5 min.
589
  """)
590