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

相关推荐
love530love6 小时前
LiveTalking 数字人项目 Windows 部署完全指南(EPGF 架构)
人工智能·windows·python·架构·livetalking·epgf
遇事不決洛必達6 小时前
【Python基础】GIL 锁是什么及其对爬虫的影响
爬虫·python·线程·进程·gil锁
CryptoPP7 小时前
快速对接东京证券交易所API数据:实战指南与代码示例
开发语言·人工智能·windows·python·信息可视化·区块链
探物 AI7 小时前
把 MambaOut 塞进 YOLOv11:会有什么样的反应
python·yolo·计算机视觉
如竟没有火炬8 小时前
最大矩阵——单调栈
数据结构·python·线性代数·算法·leetcode·矩阵
阳区欠8 小时前
【LangChain】LLM基础介绍
开发语言·python·langchain
Cosolar8 小时前
保姆级 CrewAI 教程:从零构建多智能体协作系统
人工智能·python·架构
GDAL8 小时前
使用 uv 管理 Python 版本
python·uv·版本
真实的菜8 小时前
Redis 从入门到精通(十二):典型业务场景实战 —— 排行榜、限流器、秒杀系统、Session 共享
数据库·redis·python
cup119 小时前
[开源] Meta Assistant / 告别命令行,我为一堆 Python 脚本做了一个 Windows 任务栏的“家”
windows·python·工具·nuitka·脚本运行