250618-通过Artifacts功能集成Open-WebUI与Gradio

A. 最终效果

B. 代码实例:

B.1 Gradio
python 复制代码
import gradio as gr

def greet(name):
    return f"你好,{name}!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()  # 会输出一个 URL,可用于外部 iframe 嵌入
demo.launch(server_name="0.0.0.0", server_port=7860)

# 192.168.3.69:7860
B.2 Open-WebUI-Function/Pipe
python 复制代码
from pydantic import BaseModel, Field


class Pipe:
    class Valves(BaseModel):
        MODEL_ID: str = Field(default="")

    def __init__(self):
        self.valves = self.Valves()

    def pipe(self, body: dict):
        html = """
        
```html
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <title>Gradio Interface</title>
 <style>
   html, body { margin: 0; height: 100%; }
   iframe { width: 100%; height: 100%; border: none; }
 </style>
</head>
<body>
 <iframe src="http://192.168.3.69:7860"></iframe>
</body>
</html>

C. 注意事项

  • ⭐️:要用ip地址不要用localhost

D. 思路归档

相关推荐
Sirius.z4 小时前
第R6周:LSTM实现糖尿病探索与预测
python
名字还没想好☜4 小时前
Python f-string 进阶:数字格式化、对齐填充、调试 = 号与嵌套表达式
开发语言·数据库·python·字符串格式化·f-string
·薯条大王5 小时前
经济实惠玩云服务器|一台云服务器多人共用,子账号配置教程
java·linux·运维·服务器·汇编·c++·python
Dxy12393102166 小时前
Python 如何使用 MySQL 的事务
python·mysql
今儿敲了吗10 小时前
Python ——第三方包
笔记·python
麒麟水手10 小时前
国产银河麒麟系统开发实录:跑通Streamlit,我踩过的6个坑
python
麒麟水手10 小时前
麒麟系统部署检查清单:上线前30分钟,逐项自查这4类问题
python
用户03321266636711 小时前
使用 Python 在 PDF 中添加或删除数字签名
python
代码方舟12 小时前
零信任架构实战:基于天远柠檬查出险-登记证API构建自动化车辆履约评估网关
人工智能·python·架构·自动化
估值探索者12 小时前
【Python实时盯盘与预警 #08】成交额突然放大2倍?Python窗口比较抓异动
java·开发语言·python