Skip to content

Commit 134f413

Browse files
chore: generate
1 parent f011d77 commit 134f413

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

packages/llm/src/protocols/shared.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ export const optionalNull = <const S extends Schema.Top>(schema: S) => Schema.op
2525
/** OpenAI function schemas require one flat object at the top level. */
2626
export const openAiToolInputSchema = (schema: JsonSchema.JsonSchema): JsonSchema.JsonSchema => {
2727
const variants = Array.isArray(schema.anyOf) ? schema.anyOf.filter(isRecord) : []
28-
const flattened = variants.length === 0
29-
? { ...schema, type: "object" }
30-
: {
31-
...Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "anyOf")),
32-
type: "object",
33-
properties: variants.reduce(
34-
(properties, variant) => ({ ...(isRecord(variant.properties) ? variant.properties : {}), ...properties }),
35-
{},
36-
),
37-
additionalProperties: false,
38-
}
28+
const flattened =
29+
variants.length === 0
30+
? { ...schema, type: "object" }
31+
: {
32+
...Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "anyOf")),
33+
type: "object",
34+
properties: variants.reduce(
35+
(properties, variant) => ({ ...(isRecord(variant.properties) ? variant.properties : {}), ...properties }),
36+
{},
37+
),
38+
additionalProperties: false,
39+
}
3940
const normalized = removeNullSchemas(flattened)
4041
return isRecord(normalized) ? normalized : { type: "object" }
4142
}

0 commit comments

Comments
 (0)