@artinet/sdk
Version:
A TypeScript SDK for building collaborative AI agents.
27 lines (26 loc) • 806 B
JavaScript
/**
* Copyright 2025 The Artinet Project
* SPDX-License-Identifier: Apache-2.0
*/
import { getParts } from "./part.js";
/**
* Extracts the content of an agent response.
* @param input - The input event.
* @returns The content of the input event.
*/
export function extractTextContent(input) {
const parts = getParts(input?.parts ??
input?.status?.message?.parts ??
input?.status?.message?.parts ??
input?.artifact?.parts ??
[]);
return (parts.text ??
parts.file.map((file) => file.bytes).join("\n") ??
parts.file.map((file) => file.uri).join("\n") ??
parts.data.map((data) => JSON.stringify(data)).join("\n") ??
undefined);
}
/**
* @deprecated Use extractTextContent instead.
*/
export const getContent = extractTextContent;