Skip to content

Commit 341bf2c

Browse files
committed
chore: update api
1 parent 1507b4f commit 341bf2c

File tree

7 files changed

+160
-19
lines changed

7 files changed

+160
-19
lines changed

src/api/generated/@tanstack/react-query.gen.ts

+24
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
v1GetProviderEndpoint,
1313
v1UpdateProviderEndpoint,
1414
v1DeleteProviderEndpoint,
15+
v1ConfigureAuthMaterial,
1516
v1ListWorkspaces,
1617
v1CreateWorkspace,
1718
v1ListActiveWorkspaces,
@@ -44,6 +45,9 @@ import type {
4445
V1DeleteProviderEndpointData,
4546
V1DeleteProviderEndpointError,
4647
V1DeleteProviderEndpointResponse,
48+
V1ConfigureAuthMaterialData,
49+
V1ConfigureAuthMaterialError,
50+
V1ConfigureAuthMaterialResponse,
4751
V1CreateWorkspaceData,
4852
V1CreateWorkspaceError,
4953
V1CreateWorkspaceResponse,
@@ -293,6 +297,26 @@ export const v1DeleteProviderEndpointMutation = (
293297
return mutationOptions;
294298
};
295299

300+
export const v1ConfigureAuthMaterialMutation = (
301+
options?: Partial<OptionsLegacyParser<V1ConfigureAuthMaterialData>>,
302+
) => {
303+
const mutationOptions: UseMutationOptions<
304+
V1ConfigureAuthMaterialResponse,
305+
V1ConfigureAuthMaterialError,
306+
OptionsLegacyParser<V1ConfigureAuthMaterialData>
307+
> = {
308+
mutationFn: async (localOptions) => {
309+
const { data } = await v1ConfigureAuthMaterial({
310+
...options,
311+
...localOptions,
312+
throwOnError: true,
313+
});
314+
return data;
315+
},
316+
};
317+
return mutationOptions;
318+
};
319+
296320
export const v1ListWorkspacesQueryKey = (options?: OptionsLegacyParser) => [
297321
createQueryKey("v1ListWorkspaces", options),
298322
];

src/api/generated/sdk.gen.ts

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import type {
2828
V1DeleteProviderEndpointData,
2929
V1DeleteProviderEndpointError,
3030
V1DeleteProviderEndpointResponse,
31+
V1ConfigureAuthMaterialData,
32+
V1ConfigureAuthMaterialError,
33+
V1ConfigureAuthMaterialResponse,
3134
V1ListWorkspacesError,
3235
V1ListWorkspacesResponse,
3336
V1CreateWorkspaceData,
@@ -218,6 +221,23 @@ export const v1DeleteProviderEndpoint = <ThrowOnError extends boolean = false>(
218221
});
219222
};
220223

224+
/**
225+
* Configure Auth Material
226+
* Configure auth material for a provider.
227+
*/
228+
export const v1ConfigureAuthMaterial = <ThrowOnError extends boolean = false>(
229+
options: OptionsLegacyParser<V1ConfigureAuthMaterialData, ThrowOnError>,
230+
) => {
231+
return (options?.client ?? client).put<
232+
V1ConfigureAuthMaterialResponse,
233+
V1ConfigureAuthMaterialError,
234+
ThrowOnError
235+
>({
236+
...options,
237+
url: "/api/v1/provider-endpoints/{provider_id}/auth-material",
238+
});
239+
};
240+
221241
/**
222242
* List Workspaces
223243
* List all workspaces.

src/api/generated/types.gen.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ export type CodeSnippet = {
4444
libraries?: Array<string>;
4545
};
4646

47+
/**
48+
* Represents a request to configure auth material for a provider.
49+
*/
50+
export type ConfigureAuthMaterial = {
51+
auth_type: ProviderAuthType;
52+
api_key?: string | null;
53+
};
54+
4755
/**
4856
* Represents a conversation.
4957
*/
@@ -100,10 +108,10 @@ export enum MuxMatcherType {
100108
* Represents a mux rule for a provider.
101109
*/
102110
export type MuxRule = {
103-
provider: string;
111+
provider_id: string;
104112
model: string;
105113
matcher_type: MuxMatcherType;
106-
matcher: string | null;
114+
matcher?: string | null;
107115
};
108116

109117
/**
@@ -126,7 +134,7 @@ export type ProviderEndpoint = {
126134
description?: string;
127135
provider_type: ProviderType;
128136
endpoint: string;
129-
auth_type: ProviderAuthType;
137+
auth_type?: ProviderAuthType | null;
130138
};
131139

132140
/**
@@ -263,6 +271,17 @@ export type V1DeleteProviderEndpointResponse = unknown;
263271

264272
export type V1DeleteProviderEndpointError = HTTPValidationError;
265273

274+
export type V1ConfigureAuthMaterialData = {
275+
body: ConfigureAuthMaterial;
276+
path: {
277+
provider_id: string;
278+
};
279+
};
280+
281+
export type V1ConfigureAuthMaterialResponse = void;
282+
283+
export type V1ConfigureAuthMaterialError = HTTPValidationError;
284+
266285
export type V1ListWorkspacesResponse = ListWorkspacesResponse;
267286

268287
export type V1ListWorkspacesError = unknown;

src/api/openapi.json

+86-8
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,54 @@
336336
}
337337
}
338338
},
339+
"/api/v1/provider-endpoints/{provider_id}/auth-material": {
340+
"put": {
341+
"tags": [
342+
"CodeGate API",
343+
"Providers"
344+
],
345+
"summary": "Configure Auth Material",
346+
"description": "Configure auth material for a provider.",
347+
"operationId": "v1_configure_auth_material",
348+
"parameters": [
349+
{
350+
"name": "provider_id",
351+
"in": "path",
352+
"required": true,
353+
"schema": {
354+
"type": "string",
355+
"format": "uuid",
356+
"title": "Provider Id"
357+
}
358+
}
359+
],
360+
"requestBody": {
361+
"required": true,
362+
"content": {
363+
"application/json": {
364+
"schema": {
365+
"$ref": "#/components/schemas/ConfigureAuthMaterial"
366+
}
367+
}
368+
}
369+
},
370+
"responses": {
371+
"204": {
372+
"description": "Successful Response"
373+
},
374+
"422": {
375+
"description": "Validation Error",
376+
"content": {
377+
"application/json": {
378+
"schema": {
379+
"$ref": "#/components/schemas/HTTPValidationError"
380+
}
381+
}
382+
}
383+
}
384+
}
385+
}
386+
},
339387
"/api/v1/workspaces": {
340388
"get": {
341389
"tags": [
@@ -1201,6 +1249,30 @@
12011249
],
12021250
"title": "CodeSnippet"
12031251
},
1252+
"ConfigureAuthMaterial": {
1253+
"properties": {
1254+
"auth_type": {
1255+
"$ref": "#/components/schemas/ProviderAuthType"
1256+
},
1257+
"api_key": {
1258+
"anyOf": [
1259+
{
1260+
"type": "string"
1261+
},
1262+
{
1263+
"type": "null"
1264+
}
1265+
],
1266+
"title": "Api Key"
1267+
}
1268+
},
1269+
"type": "object",
1270+
"required": [
1271+
"auth_type"
1272+
],
1273+
"title": "ConfigureAuthMaterial",
1274+
"description": "Represents a request to configure auth material for a provider."
1275+
},
12041276
"Conversation": {
12051277
"properties": {
12061278
"question_answers": {
@@ -1373,9 +1445,9 @@
13731445
},
13741446
"MuxRule": {
13751447
"properties": {
1376-
"provider": {
1448+
"provider_id": {
13771449
"type": "string",
1378-
"title": "Provider"
1450+
"title": "Provider Id"
13791451
},
13801452
"model": {
13811453
"type": "string",
@@ -1398,10 +1470,9 @@
13981470
},
13991471
"type": "object",
14001472
"required": [
1401-
"provider",
1473+
"provider_id",
14021474
"model",
1403-
"matcher_type",
1404-
"matcher"
1475+
"matcher_type"
14051476
],
14061477
"title": "MuxRule",
14071478
"description": "Represents a mux rule for a provider."
@@ -1447,15 +1518,22 @@
14471518
"title": "Endpoint"
14481519
},
14491520
"auth_type": {
1450-
"$ref": "#/components/schemas/ProviderAuthType"
1521+
"anyOf": [
1522+
{
1523+
"$ref": "#/components/schemas/ProviderAuthType"
1524+
},
1525+
{
1526+
"type": "null"
1527+
}
1528+
],
1529+
"default": "none"
14511530
}
14521531
},
14531532
"type": "object",
14541533
"required": [
14551534
"name",
14561535
"provider_type",
1457-
"endpoint",
1458-
"auth_type"
1536+
"endpoint"
14591537
],
14601538
"title": "ProviderEndpoint",
14611539
"description": "Represents a provider's endpoint configuration. This\nallows us to persist the configuration for each provider,\nso we can use this for muxing messages."

src/features/workspace/components/workspace-preferred-model.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function WorkspacePreferredModel({
2626
const { preferredModel, setPreferredModel } = usePreferredModelWorkspace();
2727
const { mutateAsync } = useMutationPreferredModelWorkspace();
2828
const { data: providerModels = [] } = useModelsData();
29-
const { model, provider } = preferredModel;
29+
const { model, provider_id } = preferredModel;
3030

3131
const handleSubmit = (event: FormEvent) => {
3232
event.preventDefault();
@@ -35,7 +35,7 @@ export function WorkspacePreferredModel({
3535
body: [
3636
{
3737
matcher: "",
38-
provider,
38+
provider_id,
3939
model,
4040
matcher_type: MuxMatcherType.CATCH_ALL,
4141
},
@@ -69,7 +69,7 @@ export function WorkspacePreferredModel({
6969
if (preferredModelProvider) {
7070
setPreferredModel({
7171
model: preferredModelProvider.name,
72-
provider: preferredModelProvider.provider_id,
72+
provider_id: preferredModelProvider.provider_id,
7373
});
7474
}
7575
}}

src/features/workspace/hooks/use-preferred-preferred-model.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ type State = {
1010

1111
export const usePreferredModelWorkspace = create<State>((set) => ({
1212
preferredModel: {
13-
provider: "",
13+
provider_id: "",
1414
model: "",
1515
},
16-
setPreferredModel: ({ model, provider }: ModelRule) => {
17-
set({ preferredModel: { provider, model } });
16+
setPreferredModel: ({ model, provider_id }: ModelRule) => {
17+
set({ preferredModel: { provider_id, model } });
1818
},
1919
}));

src/mocks/msw/handlers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ export const handlers = [
9696
http.get("*/api/v1/workspaces/:workspace_name/muxes", () =>
9797
HttpResponse.json([
9898
{
99-
provider: "openai",
99+
provider_id: "openai",
100100
model: "gpt-3.5-turbo",
101101
matcher_type: "file_regex",
102102
matcher: ".*\\.txt",
103103
},
104104
{
105-
provider: "anthropic",
105+
provider_id: "anthropic",
106106
model: "davinci",
107107
matcher_type: "catch_all",
108108
},

0 commit comments

Comments
 (0)