File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ from fastapi import APIRouter , Depends
2
+ from openai import AsyncOpenAI
3
+ from utils .create_assistant import create_or_update_assistant , request
4
+ import logging
5
+ import os
6
+ from dotenv import load_dotenv
7
+
8
+ # Configure logger
9
+ logger = logging .getLogger ("uvicorn.error" )
10
+
11
+ # Load environment variables
12
+ load_dotenv ()
13
+
14
+ router = APIRouter (
15
+ prefix = "/assistants" ,
16
+ tags = ["assistants" ]
17
+ )
18
+
19
+
20
+ @router .post ("/create-update" )
21
+ async def create_update_assistant (
22
+ client : AsyncOpenAI = Depends (lambda : AsyncOpenAI ())
23
+ ):
24
+ """
25
+ Create a new assistant or update an existing one.
26
+ Returns the assistant ID and status of the operation.
27
+ """
28
+ assistant_id = os .getenv ("ASSISTANT_ID" )
29
+
30
+ assistant_id : str = await create_or_update_assistant (
31
+ client = client ,
32
+ assistant_id = assistant_id ,
33
+ request = request ,
34
+ logger = logger
35
+ )
36
+
37
+ return {
38
+ "message" : f"Assistant { assistant_id } successfully created/updated"
39
+ }
You can’t perform that action at this time.
0 commit comments