chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @vitest-environment node
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
adaptAnthropicToolSchema,
|
||||
adaptOpenAIChatToolSchema,
|
||||
} from '@/providers/tool-schema-adapter'
|
||||
import type { ProviderToolConfig } from '@/providers/types'
|
||||
|
||||
const sampleTool: ProviderToolConfig = {
|
||||
id: 'search_web',
|
||||
name: 'Search Web',
|
||||
description: 'Search the web for a query',
|
||||
params: {},
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: { query: { type: 'string', description: 'The query' } },
|
||||
required: ['query'],
|
||||
},
|
||||
}
|
||||
|
||||
const noDescriptionTool: ProviderToolConfig = {
|
||||
id: 'noop',
|
||||
name: 'Noop',
|
||||
description: '',
|
||||
params: {},
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
required: [],
|
||||
},
|
||||
}
|
||||
|
||||
const emptyParametersTool: ProviderToolConfig = {
|
||||
id: 'ping',
|
||||
name: 'Ping',
|
||||
description: 'Ping the server',
|
||||
params: {},
|
||||
parameters: {} as ProviderToolConfig['parameters'],
|
||||
}
|
||||
|
||||
describe('adaptOpenAIChatToolSchema', () => {
|
||||
it('wraps the tool in the chat function shape', () => {
|
||||
expect(adaptOpenAIChatToolSchema(sampleTool)).toEqual({
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'search_web',
|
||||
description: 'Search the web for a query',
|
||||
parameters: sampleTool.parameters,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves an empty description', () => {
|
||||
expect(adaptOpenAIChatToolSchema(noDescriptionTool)).toEqual({
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'noop',
|
||||
description: '',
|
||||
parameters: noDescriptionTool.parameters,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('passes through empty parameters unchanged', () => {
|
||||
expect(adaptOpenAIChatToolSchema(emptyParametersTool)).toEqual({
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'ping',
|
||||
description: 'Ping the server',
|
||||
parameters: emptyParametersTool.parameters,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('adaptAnthropicToolSchema', () => {
|
||||
it('produces the Anthropic input_schema shape', () => {
|
||||
expect(adaptAnthropicToolSchema(sampleTool)).toEqual({
|
||||
name: 'search_web',
|
||||
description: 'Search the web for a query',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: sampleTool.parameters.properties,
|
||||
required: sampleTool.parameters.required,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves an empty description', () => {
|
||||
expect(adaptAnthropicToolSchema(noDescriptionTool)).toEqual({
|
||||
name: 'noop',
|
||||
description: '',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: noDescriptionTool.parameters.properties,
|
||||
required: noDescriptionTool.parameters.required,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('passes through empty parameters as undefined properties/required', () => {
|
||||
expect(adaptAnthropicToolSchema(emptyParametersTool)).toEqual({
|
||||
name: 'ping',
|
||||
description: 'Ping the server',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: undefined,
|
||||
required: undefined,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user