@@ -52,9 +52,25 @@ async def read_setup(
52
52
status : Optional [str ] = None ,
53
53
message_text : Optional [str ] = None
54
54
) -> Response :
55
- # Check if assistant ID is missing
56
- current_tools = []
57
- setup_message = "" # Message specific to setup state (e.g., API key missing)
55
+ # Variable initializations
56
+ current_tools : List [str ] = []
57
+ current_model : Optional [str ] = None
58
+ # Populate with all models extracted from user-provided HTML, sorted
59
+ available_models : List [str ] = sorted ([
60
+ "gpt-3.5-turbo" , "gpt-3.5-turbo-0125" , "gpt-3.5-turbo-1106" , "gpt-3.5-turbo-16k" ,
61
+ "gpt-4" , "gpt-4-0125-preview" , "gpt-4-0613" , "gpt-4-1106-preview" ,
62
+ "gpt-4-turbo" , "gpt-4-turbo-2024-04-09" , "gpt-4-turbo-preview" ,
63
+ "gpt-4.1" , "gpt-4.1-2025-04-14" , "gpt-4.1-mini" , "gpt-4.1-mini-2025-04-14" ,
64
+ "gpt-4.1-nano" , "gpt-4.1-nano-2025-04-14" ,
65
+ "gpt-4.5-preview" , "gpt-4.5-preview-2025-02-27" ,
66
+ "gpt-4o" , "gpt-4o-2024-05-13" , "gpt-4o-2024-08-06" , "gpt-4o-2024-11-20" ,
67
+ "gpt-4o-mini" , "gpt-4o-mini-2024-07-18" ,
68
+ "o1" , "o1-2024-12-17" ,
69
+ "o3-mini" , "o3-mini-2025-01-31"
70
+ ])
71
+ setup_message : str = ""
72
+
73
+ # Check if env variables are set
58
74
load_dotenv (override = True )
59
75
openai_api_key = os .getenv ("OPENAI_API_KEY" )
60
76
assistant_id = os .getenv ("ASSISTANT_ID" )
@@ -67,6 +83,7 @@ async def read_setup(
67
83
try :
68
84
assistant = await client .beta .assistants .retrieve (assistant_id )
69
85
current_tools = [tool .type for tool in assistant .tools ]
86
+ current_model = assistant .model # Get the model from the assistant
70
87
except Exception as e :
71
88
logger .error (f"Failed to retrieve assistant { assistant_id } : { e } " )
72
89
# If we can't retrieve the assistant, proceed as if it doesn't exist
@@ -81,14 +98,17 @@ async def read_setup(
81
98
"status" : status , # Pass status from query params
82
99
"status_message" : message_text , # Pass message from query params
83
100
"assistant_id" : assistant_id ,
84
- "current_tools" : current_tools
101
+ "current_tools" : current_tools ,
102
+ "current_model" : current_model ,
103
+ "available_models" : available_models # Pass available models to template
85
104
}
86
105
)
87
106
88
107
89
108
@router .post ("/assistant" )
90
109
async def create_update_assistant (
91
110
tool_types : List [ToolTypes ] = Form (...),
111
+ model : str = Form (...),
92
112
client : AsyncOpenAI = Depends (lambda : AsyncOpenAI ())
93
113
) -> RedirectResponse :
94
114
"""
@@ -101,6 +121,7 @@ async def create_update_assistant(
101
121
client = client ,
102
122
assistant_id = current_assistant_id ,
103
123
tool_types = tool_types ,
124
+ model = model ,
104
125
logger = logger
105
126
)
106
127
0 commit comments