|
|
|
|
|
|
|
|
|
|
|
import os |
|
import gradio as gr |
|
|
|
|
|
with gr.Blocks( |
|
fill_height=True, |
|
fill_width=True |
|
) as app: |
|
|
|
with gr.Sidebar(): |
|
|
|
gr.HTML( |
|
""" |
|
<b>Demo only! <a href="https://umint-openwebui.hf.space" |
|
target="_blank">Click here</a> to continue.</b> |
|
<br><br>Please read the <b><a href= |
|
"https://huggingface.co/spaces/umint/ai/discussions" |
|
target="_blank">discussions</a></b> before you go. |
|
<br><br>In this demo, only <b>image</b> |
|
upload are allowed. The maximum file size for an |
|
image upload is <b>1MB</b>. |
|
<b>The system will automatically reject any file that |
|
exceeds this limit.</b><br><br> |
|
It is also not permitted to input prohibited content. |
|
<b>The system will automatically return an error if an |
|
attempt is made.</b><br><br> |
|
Please read the <b><a href= |
|
"https://huggingface.co/spaces/umint/ai/discussions/37" |
|
target="_blank">Terms of Service</a></b> |
|
before deciding to move on to the more advanced |
|
version.<br><br> <b>Like this project? |
|
Feel free to buy me a <a href= |
|
"https://ko-fi.com/hadad" |
|
target="_blank">coffee</a></b>. |
|
""" |
|
) |
|
|
|
gr.load_chat( |
|
os.getenv("OPENAI_API_BASE_URL"), |
|
token=os.getenv("OPENAI_API_KEY"), |
|
model="o4-mini.pollinations", |
|
chatbot=gr.Chatbot( |
|
label="ChatGPT | o4 (Mini)", |
|
type="messages", |
|
show_copy_button=True, |
|
scale=1 |
|
), |
|
file_types=["image"], |
|
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."] |
|
], |
|
cache_examples=False, |
|
show_api=False |
|
) |
|
|
|
|
|
app.launch( |
|
max_file_size="1mb", |
|
server_name="0.0.0.0", |
|
pwa=True |
|
) |