File size: 1,094 Bytes
1e99029
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#
# SPDX-FileCopyrightText: Hadad <[email protected]>
# SPDX-License-Identifier: Apache-2.0
#

import os  # Used for accessing environment variables
import gradio as gr  # Used to create the user interface

# Gradio user interface
gr.load_chat(
    os.getenv("OPENAI_API_BASE_URL"),  # Endpoint
    token=os.getenv("OPENAI_API_KEY"),  # API Key
    model="gpt-4.1-nano",  # Model
    chatbot=gr.Chatbot(
        label="ChatGPT",  # Title
        type="messages",  # OpenAI-style messages format
        show_copy_button=True,  # Allow users to copy responses
        scale=1  # Standard display scaling
    ),
    file_types=["image"],  # Multimodal
    examples=[
        ["Please introduce yourself."],
        [{"text": "Explain about this image.",
          "files": ["assets/images/9299765.jpg"]}],
        ["Give me a short introduction to large language model."],
        ["Explain about quantum computers."]
    ],  # Provide sample inputs for users to try
    cache_examples=False,  # Ensure responses always fresh
    show_api=False  # Disable Gradio API
).launch()  # Start the app