@sap-ai-sdk/langchain
Version:
SAP Cloud SDK for AI is the official Software Development Kit (SDK) for **SAP AI Core**, **SAP Generative AI Hub**, and **Orchestration Service**.
57 lines • 2.85 kB
TypeScript
import { AIMessageChunk } from '@langchain/core/messages';
import type { Xor } from '@sap-cloud-sdk/util';
import type { ToolDefinition } from '@langchain/core/language_models/base';
import type { ChatOrchestrationToolType } from './types.js';
import type { ChatResult } from '@langchain/core/outputs';
import type { OrchestrationStreamChunkResponse, PromptTemplate } from '@sap-ai-sdk/orchestration';
import type { ChatCompletionTool, ChatMessage, CompletionPostResponse, FunctionObject, TemplateRef } from '@sap-ai-sdk/orchestration/internal.js';
import type { BaseMessage } from '@langchain/core/messages';
/**
* Maps a {@link ChatOrchestrationToolType} to {@link FunctionObject}.
* @param tool - Base class for tools that accept input of any shape defined by a Zod schema.
* @param strict - Whether to enforce strict mode for the function call.
* @returns The Orchestration chat completion function.
* @internal
*/
export declare function mapToolToOrchestrationFunction(tool: ChatOrchestrationToolType, strict?: boolean): FunctionObject;
/**
* Maps a LangChain {@link ChatOrchestrationToolType} to {@link ChatCompletionTool}.
* @param tool - Base class for tools that accept input of any shape defined by a Zod schema.
* @param strict - Whether to enforce strict mode for the function call.
* @returns The Orchestration chat completion tool.
* @internal
*/
export declare function mapToolToChatCompletionTool(tool: ChatOrchestrationToolType, strict?: boolean): ChatCompletionTool;
/**
* Checks if the object is a {@link TemplateRef}.
* @param object - The object to check.
* @returns True if the object is a {@link TemplateRef}.
* @internal
*/
export declare function isTemplateRef(object: Xor<PromptTemplate, TemplateRef>): object is TemplateRef;
/**
* Maps LangChain messages to orchestration messages.
* @param messages - The LangChain messages to map.
* @returns The orchestration messages mapped from LangChain messages.
* @internal
*/
export declare function mapLangChainMessagesToOrchestrationMessages(messages: BaseMessage[]): ChatMessage[];
/**
* Maps the completion response to a {@link ChatResult}.
* @param completionResponse - The completion response to map.
* @returns The mapped {@link ChatResult}.
* @internal
*/
export declare function mapOutputToChatResult(completionResponse: CompletionPostResponse): ChatResult;
/**
* @internal
*/
export declare function isToolDefinitionLike(tool: ChatOrchestrationToolType): tool is ChatCompletionTool | ToolDefinition;
/**
* Converts orchestration stream chunk to a LangChain message chunk.
* @param chunk - The orchestration stream chunk.
* @returns An {@link AIMessageChunk}
* @internal
*/
export declare function mapOrchestrationChunkToLangChainMessageChunk(chunk: OrchestrationStreamChunkResponse): AIMessageChunk;
//# sourceMappingURL=util.d.ts.map