@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
20 lines (19 loc) • 1.4 kB
TypeScript
import type { AssistantOutput } from "../types/index.js";
/**
* @description Reads the role of a chat message, treating anything without a string role as a user message.
* @param message {T} - Message of any provider shape.
* @returns {string} The message role, or `user` when it declares none.
*/
export declare function messageRole<T>(message: T): string;
/**
* @description Removes the arguments of every tool call in assistant messages and keeps each call's name and id: OpenAI `tool_calls` and `function_call` items, Anthropic `tool_use` blocks, AI SDK `tool-call` parts and Gemini `functionCall` parts.
* @param messages {object[]} - Messages from `assistantMessages`.
* @returns {object[]} Copies of the messages without tool-call arguments.
*/
export declare function withoutToolArguments(messages: object[]): object[];
/**
* @description Shapes a model response as an assistant message array that Langfuse renders as a conversation.
* @param output {AssistantOutput | undefined} - A text string, a reply with `text`, `reasoning` and `toolCalls`, a message array, or provider content parts.
* @returns {object[] | undefined} `[{ role: "assistant", content, tool_calls? }]`, the input untouched when it is already a message array, or `undefined` when there is no output.
*/
export declare function assistantMessages(output: AssistantOutput | undefined): object[] | undefined;