Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metadata): add nulability to schema for openai compatibility #158

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading