Repository navigation
v0.2.0
v0.2.0 - Anthropic thinking as the reference sends it; truncated answers returned
Anthropic thinking
Provider options now build the same Anthropic request here as in the PHP reference.
thinking: { enabled: true, budgetTokens: n }is sent as{ type: 'enabled', budget_tokens: n }. It used to go out verbatim, which Anthropic refuses. A budget that is not an integer becomes 1024.effortis sent asoutput_config: { effort }. It used to be dropped.withReasoning(false)wins over a thinking option.{ enabled: false },{}andfalsesend no thinking.- Any other value is sent as given:
{ type: 'adaptive' },display, and Anthropic's own{ type: 'enabled', budget_tokens: n }.
For current Claude models use:
.withProviderOptions({ thinking: { type: 'adaptive' }, effort: 'medium' })A parsed Anthropic response keeps the first thinking block's text and signature, as additionalContent.thinking and additionalContent.thinking_signature. An AssistantMessage carrying both sends the thinking block back first. Anthropic requires that block on a tool-use turn with thinking on. A thinking block whose text is empty keeps its signature.
Behaviour change: additionalContent.thinking is the first thinking block's text. It used to be every block's text joined, which one signature cannot cover.
Text documents to Anthropic
A text document is sent with media_type: text/plain whatever text/* type it declares. Anthropic accepts nothing else there, so text/markdown, text/csv, text/html or a charset parameter failed the whole request (Particle-Academy/prism#49).
Truncated answers are returned
An Anthropic or Mistral response that stops at the token limit returns its text and usage with finishReason length, instead of throwing. That matches the reference, and keeps the usage of the most expensive call. OpenAI still throws, as the reference does.
Behaviour change: code that ignores finishReason will treat a truncated Anthropic or Mistral answer as complete.
Hosted image generation
An OpenAI response that generated an image through the hosted image_generation tool returns it as additionalContent.generatedImages, in the images endpoint's shape. What the provider actually drew is in additionalContent.imageGenerationCalls: status, size, quality, output format and revised prompt.
Also
- Installing from git (
npm install github:Particle-Academy/prism-ts) builds the package, so it can be imported (#5). - A provider URL's trailing slashes and a fenced JSON block in structured output are found in linear time. Both used regular expressions that took seconds on long crafted input.
- CI checks every direct dependency against the organisation's allowlist, including at publish time.