Skip to content

Commit 273c010

Browse files
authored
add: 사용자 채팅에 메타 수퍼바이저 추가 (#141)
* add: 메타 수퍼바이저 파이프라인 추가 closes #140 * add: 메타 수퍼바이저 파이프라인 추가 closes #140
1 parent 859b7cc commit 273c010

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

docker-compose.prod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services:
3333
- ./pipelines:/app/pipelines
3434
environment:
3535
- APISERVER_HOST=backend-ma:8000
36+
- META_SUPERVISOR_HOST=meta-supervisor:8000
3637
- PIPELINES_DIR=/app/pipelines
3738
# 필요한 경우 특정 파이프라인 URL 추가 (주석 해제 후 사용)
3839
# - PIPELINES_URLS=https://github.com/open-webui/pipelines/blob/main/examples/filters/detoxify_filter_pipeline.py
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import os
2+
from typing import List, Union, Generator, Iterator
3+
from pydantic import BaseModel
4+
import requests
5+
6+
APISERVER_HOST = os.getenv("META_SUPERVISOR_HOST")
7+
8+
9+
class RequestBody(BaseModel):
10+
query: str
11+
model: str
12+
temperature: float
13+
14+
15+
class ResponseBody(BaseModel):
16+
answer: str
17+
18+
19+
class Pipeline:
20+
class Valves(BaseModel):
21+
pass
22+
23+
def __init__(self):
24+
self.name = "Meta Supervisor - Main"
25+
self.agent_name = "metasupervisor"
26+
self.endpoint = f"http://{APISERVER_HOST}/api/query"
27+
pass
28+
29+
async def on_startup(self):
30+
# This function is called when the server is started.
31+
print(f"on_startup:{__name__}")
32+
pass
33+
34+
async def on_shutdown(self):
35+
# This function is called when the server is stopped.
36+
print(f"on_shutdown:{__name__}")
37+
pass
38+
39+
def pipe(
40+
self, user_message: str, model_id: str, messages: List[dict], body: dict
41+
) -> Union[str, Generator, Iterator]:
42+
# This is where you can add your custom pipelines like RAG.
43+
print(f"pipe:{__name__}")
44+
45+
print("messages: ", messages)
46+
print("user_message: ", user_message)
47+
print("body: ", body)
48+
49+
headers = {}
50+
headers["accept"] = "application/json"
51+
headers["Content-Type"] = "application/json"
52+
53+
try:
54+
r = requests.post(
55+
url=f"{self.endpoint}",
56+
json={"query": user_message },
57+
headers=headers,
58+
)
59+
60+
r.raise_for_status()
61+
return ResponseBody(**r.json()).answer
62+
except Exception as e:
63+
return f"Error: {e}"

0 commit comments

Comments
 (0)