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

相关推荐
@游子2 分钟前
Python学习笔记-Day5
笔记·python·学习
棒棒的皮皮7 分钟前
【OpenCV】Python图像处理之数字水印
图像处理·python·opencv·计算机视觉
tomeasure10 分钟前
INTERNAL ASSERT FAILED at “/pytorch/c10/cuda/CUDACachingAllocator.cpp“:983
人工智能·pytorch·python·nvidia
追光天使15 分钟前
装饰器的作用
python·装饰器
一瞬祈望26 分钟前
【环境配置】Windows 下使用 Anaconda 创建 Python 3.8 环境 + 安装 PyTorch + CUDA(完整教程)
pytorch·windows·python
小兔崽子去哪了37 分钟前
RFM 模型 项目实战
python
昨天那个谁谁1 小时前
ROS2运行时报无法加载create_key等符号错误
c++·python·ros2
nju_spy1 小时前
python 算法题基础常用总结(比赛 or 机试 or 面试)
python·记忆化搜索·位运算·二分查找 - bisect·排序与lambda·最短路和最小生成树·堆与优先队列
Deng8723473481 小时前
自动化极验3点选验证码的识别与验证方案
运维·python·自动化
川石课堂软件测试2 小时前
自动化测试的基本概念及常用框架
数据库·python·功能测试·测试工具·单元测试·自动化·流程图