File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,7 @@ def proxy():
9797 break
9898 else :
9999 # If no known approach is found in the model name, default to 'bon'
100- approach = 'bon'
101-
100+ approach = "bon"
102101
103102 logger .info (f'Using approach { approach } , with { model } ' )
104103
@@ -166,6 +165,27 @@ def proxy():
166165 logger .debug (f'API response: { response_data } ' )
167166 return jsonify (response_data ), 200
168167
168+
169+ @app .route ('/v1/models' , methods = ['GET' ])
170+ def proxy_models ():
171+ logger .info ('Received request to /v1/models' )
172+
173+ try :
174+ if server_config ['base_url' ]:
175+ client = OpenAI (api_key = API_KEY , base_url = server_config ['base_url' ])
176+ else :
177+ client = default_client
178+
179+ # Fetch models using the OpenAI client and return the raw response
180+ models_response = client .models .list ()
181+
182+ logger .debug ('Models retrieved successfully' )
183+ return models_response .model_dump (), 200
184+ except Exception as e :
185+ logger .error (f"Error fetching models: { str (e )} " )
186+ return jsonify ({"error" : f"Error fetching models: { str (e )} " }), 500
187+
188+
169189@app .route ('/health' , methods = ['GET' ])
170190def health ():
171191 return jsonify ({"status" : "ok" }), 200
You can’t perform that action at this time.
0 commit comments