From aa5e39d1b3ce4da53523cf947dd318a2c270e2d0 Mon Sep 17 00:00:00 2001 From: "yumou.zhangym" Date: Tue, 16 Apr 2024 17:48:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0bot=E7=9A=84list?= =?UTF-8?q?=20=E5=92=8C=20detail=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.py | 3 ++- server/routers/bot.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 server/routers/bot.py diff --git a/server/main.py b/server/main.py index 1b4e6785..5d6da3fa 100644 --- a/server/main.py +++ b/server/main.py @@ -11,7 +11,7 @@ from data_class import ChatData # Import fastapi routers -from routers import health_checker, github +from routers import bot, health_checker, github open_api_key = get_env_variable("OPENAI_API_KEY") is_dev = bool(get_env_variable("IS_DEV")) @@ -33,6 +33,7 @@ app.include_router(health_checker.router) app.include_router(github.router) +app.include_router(bot.router) @app.post("/api/chat/stream", response_class=StreamingResponse) diff --git a/server/routers/bot.py b/server/routers/bot.py new file mode 100644 index 00000000..dd305de4 --- /dev/null +++ b/server/routers/bot.py @@ -0,0 +1,28 @@ +from fastapi import APIRouter, Depends, HTTPException, Query +from typing import Optional +from db.supabase.client import get_client + +router = APIRouter( + prefix="/api/bot", + tags=["bot"], + responses={404: {"description": "Not found"}}, +) + +@router.get("/list") +def get_bot_list(personal: Optional[str] = Query(None, description="Filter bots by personal category")): + supabase = get_client() + data = supabase.table("bots").select("id, created_at, updated_at, avatar, description, enable_img_generation, label, name, starters, voice, public").eq('public', 'true').execute() + return { "data": data.data, "personal": personal} + +@router.get("/detail") +def get_bot_detail(id: Optional[str] = Query(None, description="Filter bots by personal category")): + if not id : + return{ + "error": "Incomplete parameters", + "status": 400 + } + else : + supabase = get_client() + data = supabase.table("bots").select('id, created_at, updated_at, avatar, description, enable_img_generation, label, name, starters, voice, public').eq('id', id).execute() + return { "data": data.data, "status": 200} + \ No newline at end of file From fd501c78d7a06563d714ceab2f481d4c1f6a6342 Mon Sep 17 00:00:00 2001 From: "yumou.zhangym" Date: Tue, 16 Apr 2024 17:53:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20bot=E7=9A=84detail=20=E5=92=8C=20li?= =?UTF-8?q?st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.py | 4 +++- server/routers/bot.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 server/routers/bot.py diff --git a/server/main.py b/server/main.py index f68220d9..5478f52d 100644 --- a/server/main.py +++ b/server/main.py @@ -11,7 +11,7 @@ from data_class import ChatData # Import fastapi routers -from routers import health_checker, github, rag +from routers import bot, health_checker, github, rag open_api_key = get_env_variable("OPENAI_API_KEY") is_dev = bool(get_env_variable("IS_DEV")) @@ -34,6 +34,8 @@ app.include_router(health_checker.router) app.include_router(github.router) app.include_router(rag.router) +app.include_router(bot.router) + @app.post("/api/chat/stream", response_class=StreamingResponse) def run_agent_chat(input_data: ChatData): diff --git a/server/routers/bot.py b/server/routers/bot.py new file mode 100644 index 00000000..dd305de4 --- /dev/null +++ b/server/routers/bot.py @@ -0,0 +1,28 @@ +from fastapi import APIRouter, Depends, HTTPException, Query +from typing import Optional +from db.supabase.client import get_client + +router = APIRouter( + prefix="/api/bot", + tags=["bot"], + responses={404: {"description": "Not found"}}, +) + +@router.get("/list") +def get_bot_list(personal: Optional[str] = Query(None, description="Filter bots by personal category")): + supabase = get_client() + data = supabase.table("bots").select("id, created_at, updated_at, avatar, description, enable_img_generation, label, name, starters, voice, public").eq('public', 'true').execute() + return { "data": data.data, "personal": personal} + +@router.get("/detail") +def get_bot_detail(id: Optional[str] = Query(None, description="Filter bots by personal category")): + if not id : + return{ + "error": "Incomplete parameters", + "status": 400 + } + else : + supabase = get_client() + data = supabase.table("bots").select('id, created_at, updated_at, avatar, description, enable_img_generation, label, name, starters, voice, public').eq('id', id).execute() + return { "data": data.data, "status": 200} + \ No newline at end of file From 8e10468cf4f3e79d36ec270c70236e533de2e250 Mon Sep 17 00:00:00 2001 From: "yumou.zhangym" Date: Tue, 16 Apr 2024 17:59:03 +0800 Subject: [PATCH 3/3] feat: merge --- server/main.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/main.py b/server/main.py index e5a520db..5478f52d 100644 --- a/server/main.py +++ b/server/main.py @@ -11,11 +11,7 @@ from data_class import ChatData # Import fastapi routers -<<<<<<< HEAD -from routers import bot, health_checker, github -======= from routers import bot, health_checker, github, rag ->>>>>>> new-branch-name open_api_key = get_env_variable("OPENAI_API_KEY") is_dev = bool(get_env_variable("IS_DEV"))