-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Thanks for your work. it's really works well for many use cases, except one I'm struggling with
Problem Description
When using TransformersJS models (via @built-in-ai/transformers-js or the custom HuggingFace provider), the models report that they support generateObject functionality, but attempting to use structured output generation with JSON schemas fails. This causes issues in applications that rely on checking provider.generateObject availability to determine whether to use structured or text-based generation.
Current Behavior
- The provider/model reports
generateObjectis available (truthy check passes) - When calling
generateObjectwith a Zod schema, the SDK warns:"JSON response format is not supported by TransformersJS" - The generation fails with
NoObjectGeneratedError: No object generated: could not parse the response - The model returns plain text instead of structured JSON
Expected Behavior
Either:
- A) TransformersJS models should properly support structured output with JSON schemas, OR
- B) The provider should not expose
generateObjectmethod if it's not actually supported
Reproduction Steps
import { generateObject } from 'ai';
import { transformersJS } from '@built-in-ai/transformers-js';
import { z } from 'zod';
const model = transformersJS('HuggingFaceTB/SmolLM2-360M-Instruct', {
device: 'cpu'
});
// This check passes, suggesting structured output is supported
if (model.generateObject) {
console.log('✅ Model claims to support generateObject');
}
// But this fails
const result = await generateObject({
model,
schema: z.object({
feedback: z.enum(['Positive', 'Neutral', 'Negative']),
}),
prompt: 'Label this customer review: There is something wrong with your product that...'
});
// ❌ Throws: NoObjectGeneratedErrorError Output
AI SDK Warning: The "responseFormat" setting is not supported by this model - JSON response format is not supported by TransformersJS
NoObjectGeneratedError [AI_NoObjectGeneratedError]: No object generated: could not parse the response.
cause: JSONParseError [AI_JSONParseError]: JSON parsing failed: Text: Feedback: Ne...
Error message: Unexpected token 'F', "Feedback: Ne"... is not valid JSON
mikechao
Metadata
Metadata
Assignees
Labels
No labels