@@ -25,6 +25,99 @@ def uniq_name(route: APIRoute):
25
25
return f"v1_{ route .name } "
26
26
27
27
28
+ @v1 .get ("/provider-endpoints" , tags = ["Providers" ], generate_unique_id_function = uniq_name )
29
+ async def list_provider_endpoints (name : Optional [str ] = None ) -> List [v1_models .ProviderEndpoint ]:
30
+ """List all provider endpoints."""
31
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
32
+ # implementation that fetches the provider endpoints from the database.
33
+ return [
34
+ v1_models .ProviderEndpoint (
35
+ id = 1 ,
36
+ name = "dummy" ,
37
+ description = "Dummy provider endpoint" ,
38
+ endpoint = "http://example.com" ,
39
+ provider_type = v1_models .ProviderType .openai ,
40
+ auth_type = v1_models .ProviderAuthType .none ,
41
+ )
42
+ ]
43
+
44
+
45
+ @v1 .get (
46
+ "/provider-endpoints/{provider_id}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
47
+ )
48
+ async def get_provider_endpoint (provider_id : int ) -> v1_models .ProviderEndpoint :
49
+ """Get a provider endpoint by ID."""
50
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
51
+ # implementation that fetches the provider endpoint from the database.
52
+ return v1_models .ProviderEndpoint (
53
+ id = provider_id ,
54
+ name = "dummy" ,
55
+ description = "Dummy provider endpoint" ,
56
+ endpoint = "http://example.com" ,
57
+ provider_type = v1_models .ProviderType .openai ,
58
+ auth_type = v1_models .ProviderAuthType .none ,
59
+ )
60
+
61
+
62
+ @v1 .post (
63
+ "/provider-endpoints" ,
64
+ tags = ["Providers" ],
65
+ generate_unique_id_function = uniq_name ,
66
+ status_code = 201 ,
67
+ )
68
+ async def add_provider_endpoint (request : v1_models .ProviderEndpoint ) -> v1_models .ProviderEndpoint :
69
+ """Add a provider endpoint."""
70
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
71
+ # implementation that adds the provider endpoint to the database.
72
+ return request
73
+
74
+
75
+ @v1 .put (
76
+ "/provider-endpoints/{provider_id}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
77
+ )
78
+ async def update_provider_endpoint (
79
+ provider_id : int , request : v1_models .ProviderEndpoint
80
+ ) -> v1_models .ProviderEndpoint :
81
+ """Update a provider endpoint by ID."""
82
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
83
+ # implementation that updates the provider endpoint in the database.
84
+ return request
85
+
86
+
87
+ @v1 .delete (
88
+ "/provider-endpoints/{provider_id}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
89
+ )
90
+ async def delete_provider_endpoint (provider_id : int ):
91
+ """Delete a provider endpoint by id."""
92
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
93
+ # implementation that deletes the provider endpoint from the database.
94
+ return Response (status_code = 204 )
95
+
96
+
97
+ @v1 .get (
98
+ "/provider-endpoints/{provider_name}/models" ,
99
+ tags = ["Providers" ],
100
+ generate_unique_id_function = uniq_name ,
101
+ )
102
+ async def list_models_by_provider (provider_name : str ) -> List [v1_models .ModelByProvider ]:
103
+ """List models by provider."""
104
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
105
+ # implementation that fetches the models by provider from the database.
106
+ return [v1_models .ModelByProvider (name = "dummy" , provider = "dummy" )]
107
+
108
+
109
+ @v1 .get (
110
+ "/provider-endpoints/models" ,
111
+ tags = ["Providers" ],
112
+ generate_unique_id_function = uniq_name ,
113
+ )
114
+ async def list_all_models_for_all_providers () -> List [v1_models .ModelByProvider ]:
115
+ """List all models for all providers."""
116
+ # NOTE: This is a dummy implementation. In the future, we should have a proper
117
+ # implementation that fetches all the models for all providers from the database.
118
+ return [v1_models .ModelByProvider (name = "dummy" , provider = "dummy" )]
119
+
120
+
28
121
@v1 .get ("/workspaces" , tags = ["Workspaces" ], generate_unique_id_function = uniq_name )
29
122
async def list_workspaces () -> v1_models .ListWorkspacesResponse :
30
123
"""List all workspaces."""
@@ -296,6 +389,46 @@ async def delete_workspace_custom_instructions(workspace_name: str):
296
389
return Response (status_code = 204 )
297
390
298
391
392
+ @v1 .get (
393
+ "/workspaces/{workspace_name}/muxes" ,
394
+ tags = ["Workspaces" , "Muxes" ],
395
+ generate_unique_id_function = uniq_name ,
396
+ )
397
+ async def get_workspace_muxes (workspace_name : str ) -> List [v1_models .MuxRule ]:
398
+ """Get the mux rules of a workspace.
399
+
400
+ The list is ordered in order of priority. That is, the first rule in the list
401
+ has the highest priority."""
402
+ # TODO: This is a dummy implementation. In the future, we should have a proper
403
+ # implementation that fetches the mux rules from the database.
404
+ return [
405
+ v1_models .MuxRule (
406
+ provider = "openai" ,
407
+ model = "gpt-3.5-turbo" ,
408
+ matcher_type = v1_models .MuxMatcherType .file_regex ,
409
+ matcher = ".*\\ .txt" ,
410
+ ),
411
+ v1_models .MuxRule (
412
+ provider = "anthropic" ,
413
+ model = "davinci" ,
414
+ matcher_type = v1_models .MuxMatcherType .catch_all ,
415
+ ),
416
+ ]
417
+
418
+
419
+ @v1 .put (
420
+ "/workspaces/{workspace_name}/muxes" ,
421
+ tags = ["Workspaces" , "Muxes" ],
422
+ generate_unique_id_function = uniq_name ,
423
+ status_code = 204 ,
424
+ )
425
+ async def set_workspace_muxes (workspace_name : str , request : List [v1_models .MuxRule ]):
426
+ """Set the mux rules of a workspace."""
427
+ # TODO: This is a dummy implementation. In the future, we should have a proper
428
+ # implementation that sets the mux rules in the database.
429
+ return Response (status_code = 204 )
430
+
431
+
299
432
@v1 .get ("/alerts_notification" , tags = ["Dashboard" ], generate_unique_id_function = uniq_name )
300
433
async def stream_sse ():
301
434
"""
0 commit comments