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

相关推荐
站大爷IP2 分钟前
用Python 3+Qt打造你的第一个对话框:从零开始的手把手教程
python
胖墩会武术8 分钟前
OpenAI API调用教程
python·openai·api
哪 吒19 分钟前
突破亚马逊壁垒,Web Unlocker API 助您轻松获取数据
前端·网络·python·网络安全
代码老y1 小时前
爬虫技术:数据挖掘的深度探索与实践应用
人工智能·爬虫·python·数据挖掘
大模型铲屎官1 小时前
【深度学习-Day 29】PyTorch模型持久化指南:从保存到部署的第一步
人工智能·pytorch·python·深度学习·机器学习·大模型·llm
@小红花1 小时前
Python从入门到精通
开发语言·python
百锦再1 小时前
自动打电话软件设计与实现
python·django·html·api·语音·打电话
微信公众号:AI创造财富1 小时前
run docker 失败解决办法
python·docker
火车叼位2 小时前
离线安装 Python 依赖:利用 pip download 构建本地包仓库
python
yz_518 Nemo2 小时前
Django项目实战
后端·python·django