Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -270,55 +270,49 @@ def create_demo():
|
|
| 270 |
|
| 271 |
with gr.Row():
|
| 272 |
with gr.Column(scale=1):
|
| 273 |
-
api_key = gr.Textbox(label="OpenAI API Key", value="sk-kBQuM0gvNBhOHmKz43b3iQut01bsOgg8Pv76eMKguu6jvncm")
|
| 274 |
base_url = gr.Textbox(label="Base URL (optional)", value="https://api.claudeshop.top/v1")
|
| 275 |
image_input = gr.Image(label="Upload Image", type="pil")
|
| 276 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
| 277 |
submit_btn = gr.Button("Submit")
|
| 278 |
|
| 279 |
-
# with gr.Column(scale=1):
|
| 280 |
-
# json_output = gr.JSON(label="Messages JSON", visible=False)
|
| 281 |
-
|
| 282 |
with gr.Row():
|
| 283 |
output = gr.HTML(label="Response")
|
| 284 |
-
|
| 285 |
-
# # 添加JSON下载功能
|
| 286 |
-
# download_btn = gr.Button("Download Messages as JSON")
|
| 287 |
|
| 288 |
# 处理提交
|
| 289 |
-
|
| 290 |
fn=o3_chat,
|
| 291 |
inputs=[api_key, base_url, question, image_input],
|
| 292 |
outputs=[output]
|
| 293 |
)
|
| 294 |
|
| 295 |
-
#
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
|
| 316 |
gr.Markdown("""
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
""")
|
| 323 |
|
| 324 |
return demo
|
|
|
|
| 270 |
|
| 271 |
with gr.Row():
|
| 272 |
with gr.Column(scale=1):
|
| 273 |
+
api_key = gr.Textbox(label="OpenAI API Key", type="password", value="sk-kBQuM0gvNBhOHmKz43b3iQut01bsOgg8Pv76eMKguu6jvncm")
|
| 274 |
base_url = gr.Textbox(label="Base URL (optional)", value="https://api.claudeshop.top/v1")
|
| 275 |
image_input = gr.Image(label="Upload Image", type="pil")
|
| 276 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
| 277 |
submit_btn = gr.Button("Submit")
|
| 278 |
|
|
|
|
|
|
|
|
|
|
| 279 |
with gr.Row():
|
| 280 |
output = gr.HTML(label="Response")
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
# 处理提交
|
| 283 |
+
submit_btn.click(
|
| 284 |
fn=o3_chat,
|
| 285 |
inputs=[api_key, base_url, question, image_input],
|
| 286 |
outputs=[output]
|
| 287 |
)
|
| 288 |
|
| 289 |
+
# 示例部分
|
| 290 |
+
examples = [
|
| 291 |
+
[
|
| 292 |
+
"./examples/1.png",
|
| 293 |
+
"From the information on that advertising board, what is the type of this shop?"
|
| 294 |
+
],
|
| 295 |
+
[
|
| 296 |
+
"./examples/2.png",
|
| 297 |
+
"What is the diagnosis for the abnormality seen in this image?"
|
| 298 |
+
]
|
| 299 |
+
]
|
| 300 |
+
|
| 301 |
+
gr.Examples(
|
| 302 |
+
examples=examples,
|
| 303 |
+
inputs=[image_input, question],
|
| 304 |
+
outputs=[output],
|
| 305 |
+
fn=lambda img, q: o3_chat(api_key.value, base_url.value, q, img),
|
| 306 |
+
cache_examples=True,
|
| 307 |
+
label="Click any example to try it out!"
|
| 308 |
+
)
|
| 309 |
|
| 310 |
gr.Markdown("""
|
| 311 |
+
### Tips
|
| 312 |
+
1. For best results, ask specific questions
|
| 313 |
+
2. The system can execute Python code - ask for code implementations
|
| 314 |
+
3. Try uploading different types of images (photos, charts, diagrams)
|
| 315 |
+
4. You can ask follow-up questions about previous responses
|
| 316 |
""")
|
| 317 |
|
| 318 |
return demo
|