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

相关推荐
该用户已不存在14 分钟前
不知道这些工具,难怪的你的Python开发那么慢丨Python 开发必备的6大工具
前端·后端·python
Monkey的自我迭代1 小时前
Python标准库:时间与随机数全解析
前端·python·数据挖掘
SsummerC1 小时前
【leetcode100】下一个排列
python·算法·leetcode
Kelaru2 小时前
本地Qwen中医问诊小程序系统开发
python·ai·小程序·flask·project
Menger_Wen2 小时前
分析新旧因子相关性
python·机器学习·区块链
RAY_01043 小时前
Python—数据容器
开发语言·python
June bug3 小时前
【python基础】python和pycharm的下载与安装
开发语言·python·pycharm
im_AMBER4 小时前
python实践思路(草拟计划+方法)
开发语言·python
站大爷IP4 小时前
Python与JSON:结构化数据的存储艺术
python
大菠萝学姐5 小时前
基于Spring Boot和Vue的高校图书馆座位预约系统的设计与实现
java·vue.js·spring boot·后端·python·mysql·vue