Skip to content

Commit

Permalink
Merge pull request #90 from ant-xuexiao/feat/chengyue-bot
Browse files Browse the repository at this point in the history
feat: add bot service for the python gateway
  • Loading branch information
xingwanying authored Apr 17, 2024
2 parents aa96789 + 8e10468 commit 589a2da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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):
Expand Down
28 changes: 28 additions & 0 deletions server/routers/bot.py
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}

0 comments on commit 589a2da

Please sign in to comment.