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. 思路归档

相关推荐
Ratten3 分钟前
批量识别图片文字保存到 excel 中
python
WSSWWWSSW23 分钟前
Seaborn数据可视化实战:Seaborn多变量图表绘制高级教程
python·信息可视化·数据分析·matplotlib·seaborn
ShawnLeiLei1 小时前
2.3 Flink的核心概念解析
数据库·python·flink
-Xie-1 小时前
Maven(三)
python·pycharm·maven
WSSWWWSSW1 小时前
Seaborn数据可视化实战:Seaborn颜色与样式定制教程
python·信息可视化·seaborn
Boxsc_midnight2 小时前
【适合中小企业应用的Flask网站部署指南】【小白指南系列】如何在Windows Server服务器上部署Flask网站和SSL证书开启HTTPS
服务器·windows·python·flask
码界筑梦坊3 小时前
173-基于Flask的微博舆情数据分析系统
后端·python·数据分析·flask·毕业设计
nightunderblackcat4 小时前
新手向:异步编程入门asyncio最佳实践
前端·数据库·python
weixin_448617054 小时前
疏老师-python训练营-Day54Inception网络及其思考
python
windSnowLi4 小时前
Python opencv识别图片中重叠圆的圆心位置
开发语言·python·opencv