diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 71e95ba..d353515 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.20.0" + ".": "0.21.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 128bd80..4797a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.21.0 (2026-01-24) + +Full Changelog: [v0.20.0...v0.21.0](https://github.com/perplexityai/perplexity-node/compare/v0.20.0...v0.21.0) + +### Features + +* **client:** add output_text helper function for responses ([c0d707f](https://github.com/perplexityai/perplexity-node/commit/c0d707fdf492964fd45721f171387b1528040028)) + ## 0.20.0 (2026-01-23) Full Changelog: [v0.19.0...v0.20.0](https://github.com/perplexityai/perplexity-node/compare/v0.19.0...v0.20.0) diff --git a/package.json b/package.json index ce47820..5fd11bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@perplexity-ai/perplexity_ai", - "version": "0.20.0", + "version": "0.21.0", "description": "The official TypeScript library for the Perplexity API", "author": "Perplexity ", "types": "dist/index.d.ts", diff --git a/src/lib/add-output-text.ts b/src/lib/add-output-text.ts new file mode 100644 index 0000000..8b15afd --- /dev/null +++ b/src/lib/add-output-text.ts @@ -0,0 +1,41 @@ +// Custom code that persists through Stainless regeneration. +// This adds the output_text convenience property to Response objects, + +/** + * Response interface with output_text property added. + * This will match the ResponseCreateResponse type once generated. + */ +interface Response { + object: 'response'; + output: Array<{ + type: string; + content?: Array<{ + type: string; + text?: string; + }>; + }>; + output_text?: string; +} + +/** + * Adds the output_text convenience property to a Response object. + * Aggregates all output_text items from the output list. + * + * If no output_text content blocks exist, then an empty string is set. + * + * This mutates the response object in place, matching OpenAI's Node SDK pattern. + */ +export function addOutputText(rsp: Response): void { + const texts: string[] = []; + for (const output of rsp.output) { + if (output.type !== 'message') { + continue; + } + for (const content of output.content || []) { + if (content.type === 'output_text' && content.text) { + texts.push(content.text); + } + } + } + rsp.output_text = texts.join(''); +} diff --git a/src/version.ts b/src/version.ts index b4e51da..bc95435 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.20.0'; // x-release-please-version +export const VERSION = '0.21.0'; // x-release-please-version