@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**.
51 lines • 2.7 kB
TypeScript
import type { AzureOpenAiChatCompletionTool, AzureOpenAiCreateChatCompletionResponse, AzureOpenAiCreateChatCompletionRequest, AzureOpenAiFunctionParameters, AzureOpenAiFunctionObject } from '@sap-ai-sdk/foundation-models';
import type { BaseMessage } from '@langchain/core/messages';
import type { ChatResult } from '@langchain/core/outputs';
import type { AzureOpenAiChatClient } from './chat.js';
import type { AzureOpenAiChatCallOptions, ChatAzureOpenAIToolType } from './types.js';
import type { FunctionDefinition, ToolDefinition } from '@langchain/core/language_models/base';
/**
* Maps a {@link ChatAzureOpenAIToolType} to {@link AzureOpenAiFunctionObject}.
* @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 OpenAI chat completion function.
* @internal
*/
export declare function mapToolToOpenAiFunction(tool: ChatAzureOpenAIToolType, strict?: boolean): AzureOpenAiFunctionObject;
/**
* Maps a LangChain {@link ChatAzureOpenAIToolType} to {@link AzureOpenAiChatCompletionTool}.
* @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 OpenAI chat completion tool.
* @internal
*/
export declare function mapToolToOpenAiTool(tool: ChatAzureOpenAIToolType, strict?: boolean): AzureOpenAiChatCompletionTool;
/**
* Maps {@link AzureOpenAiCreateChatCompletionResponse} to LangChain's {@link ChatResult}.
* @param completionResponse - The {@link AzureOpenAiCreateChatCompletionResponse} response.
* @returns The LangChain {@link ChatResult}
* @internal
*/
export declare function mapOutputToChatResult(completionResponse: AzureOpenAiCreateChatCompletionResponse): ChatResult;
/**
* Maps LangChain's input interface to the AI SDK client's input interface
* @param client The LangChain Azure OpenAI client
* @param options The {@link AzureOpenAiChatCallOptions}
* @param messages The messages to be send
* @returns An AI SDK compatibile request
* @internal
*/
export declare function mapLangChainToAiClient(client: AzureOpenAiChatClient, messages: BaseMessage[], options?: AzureOpenAiChatCallOptions & {
promptIndex?: number;
}): AzureOpenAiCreateChatCompletionRequest;
type ToolDefinitionLike = Pick<ToolDefinition, 'type'> & {
function: Omit<FunctionDefinition, 'parameters'> & {
parameters?: AzureOpenAiFunctionParameters;
};
};
/**
* @internal
*/
export declare function isToolDefinitionLike(tool: ChatAzureOpenAIToolType): tool is ToolDefinitionLike;
export {};
//# sourceMappingURL=util.d.ts.map