Skip to content
Open
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
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/dist
**/dist-ssr
**/node_modules
**/.next
**/.turbo
*.tsbuildinfo
*.log
4 changes: 2 additions & 2 deletions packages/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"clean": "del-cli dist docs *.tsbuildinfo",
"prepack": "cp -r ../../content/docs ./docs",
"postpack": "del-cli docs",
"lint": "eslint \"./**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\" \"internal.d.ts\" \"test.d.ts\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\" \"internal.d.ts\" \"test.d.ts\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/baseten/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"scripts": {
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "rm -rf dist docs *.tsbuildinfo",
"clean": "del-cli dist docs *.tsbuildinfo",
"prepack": "mkdir -p docs && cp ../../content/providers/01-ai-sdk-providers/170-baseten.mdx ./docs/",
"postpack": "del-cli docs",
"lint": "eslint \"./**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/huggingface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"scripts": {
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "rm -rf dist docs *.tsbuildinfo",
"clean": "del-cli dist docs *.tsbuildinfo",
"prepack": "mkdir -p docs && cp ../../content/providers/01-ai-sdk-providers/170-huggingface.mdx ./docs/",
"postpack": "del-cli docs",
"lint": "eslint \"./**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"scripts": {
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "rm -rf dist *.tsbuildinfo",
"lint": "eslint \"./**/*.ts*\"",
"clean": "del-cli dist *.tsbuildinfo",
"lint": "eslint \"src/**/*.ts*\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/provider-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "del-cli dist *.tsbuildinfo",
"lint": "eslint \"./**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\" \"test.d.ts\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\" \"test.d.ts\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down
27 changes: 27 additions & 0 deletions packages/provider-utils/src/schema-deepseek-fix.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest';
import { asSchema, jsonSchema } from './schema';

describe('DeepSeek/OpenAI-compatible schema fix', () => {
it('should add type: object to default empty schema in asSchema(undefined)', async () => {
const schema = asSchema(undefined);
expect(await schema.jsonSchema).toStrictEqual({
type: 'object',
properties: {},
additionalProperties: false,
});
});

it('should add type: object when properties are present but type is missing in jsonSchema', async () => {
const schema = jsonSchema({
properties: {
test: { type: 'string' },
},
});
expect(await schema.jsonSchema).toStrictEqual({
type: 'object',
properties: {
test: { type: 'string' },
},
});
});
});
31 changes: 29 additions & 2 deletions packages/provider-utils/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,30 @@ export function jsonSchema<OBJECT = unknown>(
if (typeof jsonSchema === 'function') {
jsonSchema = jsonSchema(); // cache the function results
}
return jsonSchema;

const fixSchema = (schema: JSONSchema7): JSONSchema7 => {
// Ensure 'type: object' is present when properties are present (required by some providers):
if (
typeof schema === 'object' &&
schema !== null &&
'properties' in schema &&
!('type' in schema)
) {
return { ...schema, type: 'object' as const };
}
return schema;
};

if (
typeof jsonSchema === 'object' &&
jsonSchema !== null &&
'then' in jsonSchema &&
typeof (jsonSchema as any).then === 'function'
) {
return (jsonSchema as PromiseLike<JSONSchema7>).then(fixSchema);
}

return fixSchema(jsonSchema as JSONSchema7);
},
validate,
};
Expand All @@ -133,7 +156,11 @@ export function asSchema<OBJECT>(
schema: FlexibleSchema<OBJECT> | undefined,
): Schema<OBJECT> {
return schema == null
? jsonSchema({ properties: {}, additionalProperties: false })
? jsonSchema({
type: 'object',
properties: {},
additionalProperties: false,
})
: isSchema(schema)
? schema
: '~standard' in schema
Expand Down
4 changes: 2 additions & 2 deletions packages/provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "del-cli dist *.tsbuildinfo",
"lint": "eslint \"./**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\""
"prettier-check": "prettier --check \"src/**/*.ts*\""
},
"exports": {
"./package.json": "./package.json",
Expand Down
8 changes: 4 additions & 4 deletions packages/test-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"scripts": {
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
"build:watch": "pnpm clean && tsup --watch",
"clean": "rm -rf dist *.tsbuildinfo",
"lint": "eslint \"./**/*.ts*\"",
"clean": "del-cli dist docs *.tsbuildinfo",
"lint": "eslint \"src/**/*.ts*\"",
"type-check": "tsc --build",
"prettier-check": "prettier --check \"./**/*.ts*\"",
"prettier-check": "prettier --check \"src/**/*.ts*\"",
"test": "pnpm test:node && pnpm test:edge",
"test:update": "pnpm test:node -u",
"test:watch": "vitest --config vitest.node.config.js",
Expand Down Expand Up @@ -71,4 +71,4 @@
"test-server",
"msw"
]
}
}