diff --git a/tests/integration/client-typescript/__tests__/responses.test.ts b/tests/integration/client-typescript/__tests__/responses.test.ts index ef0f4eef1..0fc2a3245 100644 --- a/tests/integration/client-typescript/__tests__/responses.test.ts +++ b/tests/integration/client-typescript/__tests__/responses.test.ts @@ -11,8 +11,7 @@ * IMPORTANT: Test cases and IDs must match EXACTLY with Python tests to use recorded API responses. */ -import { createTestClient, requireTextModel } from '../setup'; -import { getResponseOutputText } from 'llama-stack-client'; +import { createTestClient, requireTextModel, getResponseOutputText } from '../setup'; describe('Responses API - Basic', () => { // Test cases matching llama-stack/tests/integration/responses/fixtures/test_cases.py diff --git a/tests/integration/client-typescript/setup.ts b/tests/integration/client-typescript/setup.ts index 2943d15cf..82bc03087 100644 --- a/tests/integration/client-typescript/setup.ts +++ b/tests/integration/client-typescript/setup.ts @@ -149,3 +149,41 @@ export function requireEmbeddingModel(): string { } return TEST_CONFIG.embeddingModel; } + +/** + * Extracts aggregated text output from a ResponseObject. + * This concatenates all text content from the response's output array. + * + * Copied from llama-stack-client's response-helpers until it's available in published version. + */ +export function getResponseOutputText(response: any): string { + const pieces: string[] = []; + + for (const output of response.output ?? []) { + if (!output || output.type !== 'message') { + continue; + } + + const content = output.content; + if (typeof content === 'string') { + pieces.push(content); + continue; + } + + if (!Array.isArray(content)) { + continue; + } + + for (const item of content) { + if (typeof item === 'string') { + pieces.push(item); + continue; + } + if (item && item.type === 'output_text' && 'text' in item && typeof item.text === 'string') { + pieces.push(item.text); + } + } + } + + return pieces.join(''); +}