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

相关推荐
星核0penstarry7 小时前
试一试用gr.Workflow把AI多步骤串联变成可视化画布
人工智能·python·ai作画·api·ai编程·工作流·api聚合平台
taller_20007 小时前
【005】PiE 与传统 VBA 的核心区别
python·vba·pie·py
海兰7 小时前
【应用】基于 Next.js 16 + Python mplfinance的金融K线图与技术指标可视化平台(一)
javascript·python·金融
大衛說7 小时前
《Python 从入门到精通》系列总览与学习路线
开发语言·python·学习
小猴子爱上树8 小时前
跨境电商翻译工具推荐:批量图片翻译、视频字幕翻译、智能抠图一站式搞定
人工智能·python·音视频
丈剑走天涯8 小时前
基于 Python 3 语法的 PyCharm 练习示例,涵盖列表操作、类型判断及数据清洗等核心知识点
windows·python·pycharm
————A9 小时前
Agent 接收用户上传文件
人工智能·笔记·python·状态模式
可乐鸡翅yeah_9 小时前
hls.js 内存泄漏实战排查,直播 M3U8 长时间播放异常定位方案
开发语言·javascript·python·django·ecmascript·m3u8·m3u8在线
可乐鸡翅yeah_9 小时前
第三方接口对接 M3U8 流媒体排坑实战,解决外部服务商流兼容难题
前端·javascript·python·django·html·m3u8·m3u8在线
金融小师妹9 小时前
多因子智能推演:黄金震荡回升,杰克逊霍尔“沃什首秀”政策如何重塑金价路径的AI预测框架
大数据·人工智能·python·线性回归