@@ -25,6 +25,86 @@ def uniq_name(route: APIRoute):
2525 return f"v1_{ route .name } "
2626
2727
28+ @v1 .get ("/provider-endpoints" , tags = ["Providers" ], generate_unique_id_function = uniq_name )
29+ async def list_provider_endpoints () -> 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 list (
34+ v1_models .ProviderEndpoint (
35+ name = "dummy" ,
36+ description = "Dummy provider endpoint" ,
37+ endpoint = "http://example.com" ,
38+ provider_type = v1_models .ProviderType .openai ,
39+ auth_type = v1_models .ProviderAuthType .none ,
40+ )
41+ )
42+
43+
44+ # QUESTION: Should we normalize the provider names to lowercase?
45+ @v1 .get (
46+ "/provider-endpoints/{provider_name}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
47+ )
48+ async def get_provider_endpoint (provider_name : str ) -> v1_models .ProviderEndpoint :
49+ """Get a provider endpoint by name."""
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+ name = "dummy" ,
54+ description = "Dummy provider endpoint" ,
55+ endpoint = "http://example.com" ,
56+ provider_type = v1_models .ProviderType .openai ,
57+ auth_type = v1_models .ProviderAuthType .none ,
58+ )
59+
60+
61+ @v1 .post (
62+ "/provider-endpoints" ,
63+ tags = ["Providers" ],
64+ generate_unique_id_function = uniq_name ,
65+ status_code = 201 ,
66+ )
67+ async def add_provider_endpoint (request : v1_models .ProviderEndpoint ) -> v1_models .ProviderEndpoint :
68+ """Add a provider endpoint."""
69+ # NOTE: This is a dummy implementation. In the future, we should have a proper
70+ # implementation that adds the provider endpoint to the database.
71+ return request
72+
73+
74+ @v1 .put (
75+ "/provider-endpoints/{provider_name}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
76+ )
77+ async def update_provider_endpoint (
78+ provider_name : str , request : v1_models .ProviderEndpoint
79+ ) -> v1_models .ProviderEndpoint :
80+ """Update a provider endpoint by name."""
81+ # NOTE: This is a dummy implementation. In the future, we should have a proper
82+ # implementation that updates the provider endpoint in the database.
83+ return request
84+
85+
86+ @v1 .delete (
87+ "/provider-endpoints/{provider_name}" , tags = ["Providers" ], generate_unique_id_function = uniq_name
88+ )
89+ async def delete_provider_endpoint (provider_name : str ):
90+ """Delete a provider endpoint by name."""
91+ # NOTE: This is a dummy implementation. In the future, we should have a proper
92+ # implementation that deletes the provider endpoint from the database.
93+ return Response (status_code = 204 )
94+
95+
96+ @v1 .get (
97+ "/provider-endpoints/{provider_name}/models" ,
98+ tags = ["Providers" ],
99+ generate_unique_id_function = uniq_name ,
100+ )
101+ async def list_models_by_provider (provider_name : str ) -> List [v1_models .ModelByProvider ]:
102+ """List models by provider."""
103+ # NOTE: This is a dummy implementation. In the future, we should have a proper
104+ # implementation that fetches the models by provider from the database.
105+ return list (v1_models .ModelByProvider (name = "dummy" , provider = "dummy" ))
106+
107+
28108@v1 .get ("/workspaces" , tags = ["Workspaces" ], generate_unique_id_function = uniq_name )
29109async def list_workspaces () -> v1_models .ListWorkspacesResponse :
30110 """List all workspaces."""
@@ -296,6 +376,46 @@ async def delete_workspace_custom_instructions(workspace_name: str):
296376 return Response (status_code = 204 )
297377
298378
379+ @v1 .get (
380+ "/workspaces/{workspace_name}/muxes" ,
381+ tags = ["Workspaces" , "Muxes" ],
382+ generate_unique_id_function = uniq_name ,
383+ )
384+ async def get_workspace_muxes (workspace_name : str ) -> List [v1_models .MuxRule ]:
385+ """Get the mux rules of a workspace.
386+
387+ The list is ordered in order of priority. That is, the first rule in the list
388+ has the highest priority."""
389+ # TODO: This is a dummy implementation. In the future, we should have a proper
390+ # implementation that fetches the mux rules from the database.
391+ return [
392+ v1_models .MuxRule (
393+ provider = "openai" ,
394+ model = "gpt-3.5-turbo" ,
395+ matcher_type = v1_models .MuxMatcherType .file_regex ,
396+ matcher = ".*\\ .txt" ,
397+ ),
398+ v1_models .MuxRule (
399+ provider = "anthropic" ,
400+ model = "davinci" ,
401+ matcher_type = v1_models .MuxMatcherType .catch_all ,
402+ ),
403+ ]
404+
405+
406+ @v1 .put (
407+ "/workspaces/{workspace_name}/muxes" ,
408+ tags = ["Workspaces" , "Muxes" ],
409+ generate_unique_id_function = uniq_name ,
410+ status_code = 204 ,
411+ )
412+ async def set_workspace_muxes (workspace_name : str , request : List [v1_models .MuxRule ]):
413+ """Set the mux rules of a workspace."""
414+ # TODO: This is a dummy implementation. In the future, we should have a proper
415+ # implementation that sets the mux rules in the database.
416+ return Response (status_code = 204 )
417+
418+
299419@v1 .get ("/alerts_notification" , tags = ["Dashboard" ], generate_unique_id_function = uniq_name )
300420async def stream_sse ():
301421 """
0 commit comments