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

相关推荐
Shun_Tianyou14 分钟前
Python Day17 面向对象 及例题分析
开发语言·数据结构·python·算法
a cool fish(无名)31 分钟前
8.1-使用向量存储值列表
人工智能·python·算法
Dreamsi_zh41 分钟前
Python爬虫07_Requests爬取图片
开发语言·爬虫·python
大虫小呓2 小时前
Python So Easy 大虫小呓三部曲 - 进阶篇
python·编程语言
万粉变现经纪人2 小时前
如何解决pip安装报错ModuleNotFoundError: No module named ‘plotly’问题
python·scrapy·plotly·pycharm·flask·pandas·pip
封奚泽优2 小时前
使用Python制造扫雷游戏
开发语言·python·游戏·pygame·扫雷·random
喵手2 小时前
Spring Boot 异常处理:从全局捕获到优化用户体验!
spring boot·python·ux
魂尾ac2 小时前
因为想开发新项目了~~要给老Python项目整个虚拟环境
开发语言·python
LYue~2 小时前
7月31号打卡
python