-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from ant-xuexiao/feat/chengyue-bot
feat: add bot service for the python gateway
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
|