Skip to content

Commit

Permalink
feat (provider/xai): Support structured output for latest models. (#4251
Browse files Browse the repository at this point in the history
)
  • Loading branch information
shaper authored Jan 10, 2025
1 parent 6b2303b commit 7611964
Show file tree
Hide file tree
Showing 21 changed files with 1,535 additions and 1,626 deletions.
7 changes: 7 additions & 0 deletions .changeset/tall-moles-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@ai-sdk/google': patch
'@ai-sdk/openai-compatible': patch
'@ai-sdk/xai': patch
---

feat (provider/xai): Support structured output for latest models.
68 changes: 43 additions & 25 deletions examples/ai-core/src/e2e/deepinfra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,57 @@ import 'dotenv/config';
import { expect } from 'vitest';
import { deepinfra as provider, DeepInfraErrorData } from '@ai-sdk/deepinfra';
import { APICallError } from 'ai';
import { createFeatureTestSuite } from './feature-test-suite';
import {
createEmbeddingModelWithCapabilities,
createFeatureTestSuite,
createLanguageModelWithCapabilities,
} from './feature-test-suite';

const createChatModel = (modelId: string) =>
createLanguageModelWithCapabilities(provider.chatModel(modelId));

const createCompletionModel = (modelId: string) =>
createLanguageModelWithCapabilities(provider.completionModel(modelId), [
'textCompletion',
]);

createFeatureTestSuite({
name: 'DeepInfra',
models: {
invalidModel: provider.chatModel('no-such-model'),
languageModels: [
provider.chatModel('deepseek-ai/DeepSeek-V3'), // no tools, streaming objects, or images
provider.chatModel('google/codegemma-7b-it'), // no tools, objects, or images
provider.chatModel('google/gemma-2-9b-it'), // no tools, objects, or images
provider.chatModel('meta-llama/Llama-3.2-11B-Vision-Instruct'), // no tools, *does* support images
provider.chatModel('meta-llama/Llama-3.2-90B-Vision-Instruct'), // no tools, *does* support images
provider.chatModel('meta-llama/Llama-3.3-70B-Instruct-Turbo'), // no image input
provider.chatModel('meta-llama/Llama-3.3-70B-Instruct'), // no image input
provider.chatModel('meta-llama/Meta-Llama-3.1-405B-Instruct'), // no image input
provider.chatModel('meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo'), // no image input
provider.chatModel('meta-llama/Meta-Llama-3.1-70B-Instruct'), // no image input
provider.chatModel('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'), // no *streaming* tools, no image input
provider.chatModel('meta-llama/Meta-Llama-3.1-8B-Instruct'), // no image input
provider.chatModel('microsoft/WizardLM-2-8x22B'), // no objects, tools, or images
provider.chatModel('mistralai/Mixtral-8x7B-Instruct-v0.1'), // no *streaming* tools, no image input
provider.chatModel('nvidia/Llama-3.1-Nemotron-70B-Instruct'), // no images
provider.chatModel('Qwen/Qwen2-7B-Instruct'), // no tools, no image input
provider.chatModel('Qwen/Qwen2.5-72B-Instruct'), // no images
provider.chatModel('Qwen/Qwen2.5-Coder-32B-Instruct'), // no tool calls, no image input
provider.chatModel('Qwen/QwQ-32B-Preview'), // no tools, no image input
provider.completionModel('meta-llama/Meta-Llama-3.1-8B-Instruct'),
provider.completionModel('Qwen/Qwen2-7B-Instruct'),
createChatModel('deepseek-ai/DeepSeek-V3'), // no tools, streaming objects, or images
// createChatModel('google/codegemma-7b-it'), // no tools, objects, or images
// createChatModel('google/gemma-2-9b-it'), // no tools, objects, or images
// createChatModel('meta-llama/Llama-3.2-11B-Vision-Instruct'), // no tools, *does* support images
// createChatModel('meta-llama/Llama-3.2-90B-Vision-Instruct'), // no tools, *does* support images
// createChatModel('meta-llama/Llama-3.3-70B-Instruct-Turbo'), // no image input
// createChatModel('meta-llama/Llama-3.3-70B-Instruct'), // no image input
// createChatModel('meta-llama/Meta-Llama-3.1-405B-Instruct'), // no image input
// createChatModel('meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo'), // no image input
// createChatModel('meta-llama/Meta-Llama-3.1-70B-Instruct'), // no image input
// createChatModel('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'), // no *streaming* tools, no image input
// createChatModel('meta-llama/Meta-Llama-3.1-8B-Instruct'), // no image input
// createChatModel('microsoft/WizardLM-2-8x22B'), // no objects, tools, or images
// createChatModel('mistralai/Mixtral-8x7B-Instruct-v0.1'), // no *streaming* tools, no image input
// createChatModel('nvidia/Llama-3.1-Nemotron-70B-Instruct'), // no images
// createChatModel('Qwen/Qwen2-7B-Instruct'), // no tools, no image input
// createChatModel('Qwen/Qwen2.5-72B-Instruct'), // no images
// createChatModel('Qwen/Qwen2.5-Coder-32B-Instruct'), // no tool calls, no image input
// createChatModel('Qwen/QwQ-32B-Preview'), // no tools, no image input
// createCompletionModel('meta-llama/Meta-Llama-3.1-8B-Instruct'),
// createCompletionModel('Qwen/Qwen2-7B-Instruct'),
],
embeddingModels: [
provider.textEmbeddingModel('BAAI/bge-base-en-v1.5'),
provider.textEmbeddingModel('intfloat/e5-base-v2'),
provider.textEmbeddingModel('sentence-transformers/all-mpnet-base-v2'),
createEmbeddingModelWithCapabilities(
provider.textEmbeddingModel('BAAI/bge-base-en-v1.5'),
),
createEmbeddingModelWithCapabilities(
provider.textEmbeddingModel('intfloat/e5-base-v2'),
),
createEmbeddingModelWithCapabilities(
provider.textEmbeddingModel('sentence-transformers/all-mpnet-base-v2'),
),
],
},
timeout: 10000,
Expand Down
10 changes: 8 additions & 2 deletions examples/ai-core/src/e2e/deepseek.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import 'dotenv/config';
import { expect } from 'vitest';
import { deepseek as provider } from '@ai-sdk/deepseek';
import { APICallError } from 'ai';
import { createFeatureTestSuite } from './feature-test-suite';
import {
createFeatureTestSuite,
createLanguageModelWithCapabilities,
} from './feature-test-suite';
import { DeepSeekErrorData } from '@ai-sdk/deepseek';

const createChatModel = (modelId: string) =>
createLanguageModelWithCapabilities(provider.chat(modelId));

createFeatureTestSuite({
name: 'DeepSeek',
models: {
invalidModel: provider.chat('no-such-model'),
languageModels: [provider.chat('deepseek-chat')],
languageModels: [createChatModel('deepseek-chat')],
},
timeout: 10000,
customAssertions: {
Expand Down
Loading

0 comments on commit 7611964

Please sign in to comment.