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