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

相关推荐
Destiny_where20 分钟前
Agent平台-RAGFlow(2)-源码安装
python·ai
molunnnn1 小时前
第四章 Agent的几种经典范式
开发语言·python
linuxxx1102 小时前
django测试缓存命令的解读
python·缓存·django
毕设源码-邱学长3 小时前
【开题答辩全过程】以 基于Python的Bilibili平台数据分析与可视化实现为例,包含答辩的问题和答案
开发语言·python·数据分析
咚咚王者4 小时前
人工智能之编程进阶 Python高级:第十一章 过渡项目
开发语言·人工智能·python
A尘埃4 小时前
大模型应用python+Java后端+Vue前端的整合
java·前端·python
A尘埃4 小时前
LLM大模型评估攻略
开发语言·python
一晌小贪欢5 小时前
【Python办公】处理 CSV和Excel 文件操作指南
开发语言·python·excel·excel操作·python办公·csv操作
檀越剑指大厂6 小时前
【Python系列】fastapi和flask中的阻塞问题
python·flask·fastapi