o4-mini: Guard with blocks.
Browse files
app.py
CHANGED
@@ -7,37 +7,64 @@ import os # Used for accessing environment variables
|
|
7 |
import gradio as gr # Used to create the user interface
|
8 |
|
9 |
# Gradio user interface
|
10 |
-
gr.
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import gradio as gr # Used to create the user interface
|
8 |
|
9 |
# Gradio user interface
|
10 |
+
with gr.Blocks(
|
11 |
+
fill_height=True, # Adjusting to the height of the user's screen
|
12 |
+
fill_width=True # Adjusting to the width of the user's screen
|
13 |
+
) as app:
|
14 |
+
# Sidebar
|
15 |
+
with gr.Sidebar():
|
16 |
+
# Project description
|
17 |
+
gr.HTML(
|
18 |
+
"""
|
19 |
+
<b>Demo only! <a href="https://umint-openwebui.hf.space"
|
20 |
+
target="_blank">Click here</a> to continue.</b>
|
21 |
+
<br><br>Please read the <b><a href=
|
22 |
+
"https://huggingface.co/spaces/umint/ai/discussions"
|
23 |
+
target="_blank">discussions</a></b> before you go.
|
24 |
+
<br><br>In this demo, only <b>image</b>
|
25 |
+
upload are allowed. The maximum file size for an
|
26 |
+
image upload is <b>1MB</b>.
|
27 |
+
<b>The system will automatically reject any file that
|
28 |
+
exceeds this limit.</b><br><br>
|
29 |
+
It is also not permitted to input prohibited content.
|
30 |
+
<b>The system will automatically return an error if an
|
31 |
+
attempt is made.</b><br><br>
|
32 |
+
Please read the <b><a href=
|
33 |
+
"https://huggingface.co/spaces/umint/ai/discussions/37"
|
34 |
+
target="_blank">Terms of Service</a></b>
|
35 |
+
before deciding to move on to the more advanced
|
36 |
+
version.<br><br> <b>Like this project?
|
37 |
+
Feel free to buy me a <a href=
|
38 |
+
"https://ko-fi.com/hadad"
|
39 |
+
target="_blank">coffee</a></b>.
|
40 |
+
"""
|
41 |
+
)
|
42 |
+
# Load chat interface
|
43 |
+
gr.load_chat(
|
44 |
+
os.getenv("OPENAI_API_BASE_URL"), # Endpoint
|
45 |
+
token=os.getenv("OPENAI_API_KEY"), # API Key
|
46 |
+
model="o4-mini.pollinations", # Model
|
47 |
+
chatbot=gr.Chatbot(
|
48 |
+
label="ChatGPT | o4 (Mini)", # Chatbot title
|
49 |
+
type="messages", # OpenAI-style messages format
|
50 |
+
show_copy_button=True, # Allow users to copy responses
|
51 |
+
scale=1 # Standard display scaling
|
52 |
+
),
|
53 |
+
file_types=["image"], # Multimodal
|
54 |
+
examples=[
|
55 |
+
["Please introduce yourself."],
|
56 |
+
[{"text": "Explain about this image.",
|
57 |
+
"files": ["assets/images/9299765.jpg"]}],
|
58 |
+
["Give me a short introduction to large language model."],
|
59 |
+
["Explain about quantum computers."]
|
60 |
+
], # Provide sample inputs for users to try
|
61 |
+
cache_examples=False, # Ensure responses always fresh
|
62 |
+
show_api=False # Disable Gradio API
|
63 |
+
)
|
64 |
+
|
65 |
+
# Start the app
|
66 |
+
app.launch(
|
67 |
+
max_file_size="1mb", # Max image upload size limit
|
68 |
+
server_name="0.0.0.0", # Listen on all network interfaces
|
69 |
+
pwa=True # Progressive Web App
|
70 |
+
)
|