Skip to content

Commit

Permalink
fix(metadata): add nulability to schema for openai compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Pilar <[email protected]>
  • Loading branch information
pilartomas committed Jan 20, 2025
1 parent 2a8f729 commit f7804b7
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/artifacts/artifacts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function createArtifact(body: ArtifactCreateBody): Promise<Artifact
thread: message && ref(message.thread),
message: message && ref(message),
sourceCode: body.source_code,
metadata: body.metadata,
metadata: body.metadata ?? undefined,
accessToken: body.shared === true ? getToken() : undefined,
name: body.name,
description: body.description
Expand Down
2 changes: 1 addition & 1 deletion src/assistants/assistants.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export async function createAssistant({
instructions: instructions ?? undefined,
name: name ?? undefined,
description: description ?? undefined,
metadata,
metadata: metadata ?? undefined,
topP: top_p ?? undefined,
model: model ?? defaultAIProvider.createAssistantBackend().modelId,
agent,
Expand Down
2 changes: 1 addition & 1 deletion src/messages/messages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function createMessageEntity({
thread: ref(thread),
role,
content,
metadata,
metadata: metadata ?? undefined,
attachments: _attachments,
order
});
Expand Down
2 changes: 1 addition & 1 deletion src/runs/runs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export async function createRun({
tools: toolsParam?.map(createToolUsage) ?? assistant.tools,
instructions: instructions ?? assistant.instructions,
additionalInstructions: additionalInstructions ?? undefined,
metadata,
metadata: metadata ?? undefined,
model: model ?? assistant.model,
topP: top_p ?? assistant.topP,
temperature: temperature ?? assistant.temperature,
Expand Down
3 changes: 2 additions & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const metadataSchema = {
patternProperties: {
'.*': { type: 'string', maxLength: 512 }
},
additionalProperties: true
additionalProperties: true,
nullable: true
} as const satisfies JSONSchema;

export const createPaginationQuerySchema = <T extends readonly string[]>(
Expand Down
2 changes: 1 addition & 1 deletion src/threads/threads.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function createThread({
}: ThreadCreateBody): Promise<ThreadCreateResponse> {
const thread = new Thread({
toolResources: await createToolResources(tool_resources),
metadata
metadata: metadata ?? undefined
});
ORM.em.persist(thread);
const threadMessages = await Promise.all(
Expand Down
6 changes: 3 additions & 3 deletions src/tools/tools.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ async function createCodeInterpreterTool(
sourceCode: body.source_code,
jsonSchema: customTool.inputSchema(),
description: customTool.description,
metadata: body.metadata,
metadata: body.metadata ?? undefined,
userDescription: body.user_description
});

Expand Down Expand Up @@ -746,7 +746,7 @@ async function createOpenApiTool(
name: body.name ?? schema.info.title,
description: schema.info.description,
apiKey: body.api_key ? encrypt(body.api_key) : undefined,
metadata: body.metadata,
metadata: body.metadata ?? undefined,
userDescription: body.user_description
});

Expand All @@ -762,7 +762,7 @@ async function createFunctionTool(
name: body.name,
description: body.description ?? '',
parameters: body.parameters,
metadata: body.metadata,
metadata: body.metadata ?? undefined,
userDescription: body.user_description
});

Expand Down
2 changes: 1 addition & 1 deletion src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function createUser({
externalId,
email,
name,
metadata,
metadata: metadata ?? undefined,
defaultOrganization: ORM.em
.getRepository(Organization)
.getReference('placeholder', { wrapped: true }),
Expand Down

0 comments on commit f7804b7

Please sign in to comment.