Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@sap-ai-sdk/langchain
Advanced tools
This package provides LangChain model clients built on top of the foundation model clients of the SAP Cloud SDK for AI.
$ npm install @sap-ai-sdk/langchain
.env
file in the root of your directory.AICORE_SERVICE_KEY='<content-of-service-key>'
.This package offers both chat and embedding clients, currently supporting Azure OpenAI. All clients comply with LangChain's interface.
To initialize a client, provide the model name:
import {
AzureOpenAiChatClient,
AzureOpenAiEmbeddingClient
} from '@sap-ai-sdk/langchain';
// For a chat client
const chatClient = new AzureOpenAiChatClient({ modelName: 'gpt-4o' });
// For an embedding client
const embeddingClient = new AzureOpenAiEmbeddingClient({ modelName: 'gpt-4o' });
In addition to the default parameters of the model vendor (e.g., OpenAI) and LangChain, additional parameters can be used to help narrow down the search for the desired model:
const chatClient = new AzureOpenAiChatClient({
modelName: 'gpt-4o',
modelVersion: '24-07-2021',
resourceGroup: 'my-resource-group'
});
The chat client allows you to interact with Azure OpenAI chat models, accessible via the generative AI hub of SAP AI Core. To invoke the client, simply pass a prompt:
const response = await chatClient.invoke("What's the capital of France?");
import { AzureOpenAiChatClient } from '@sap-ai-sdk/langchain';
import { StringOutputParser } from '@langchain/core/output_parsers';
import { ChatPromptTemplate } from '@langchain/core/prompts';
const client = new AzureOpenAiChatClient({ modelName: 'gpt-35-turbo' });
const promptTemplate = ChatPromptTemplate.fromMessages([
['system', 'Answer the following in {language}:'],
['user', '{text}']
]);
const parser = new StringOutputParser();
const llmChain = promptTemplate.pipe(client).pipe(parser);
const response = await llmChain.invoke({
language: 'german',
text: 'What is the capital of France?'
});
Embedding clients allow embedding either text or documents (represented as arrays of strings).
const embeddedText = await embeddingClient.embedQuery(
'Paris is the capital of France.'
);
const embeddedDocument = await embeddingClient.embedDocuments([
'Page 1: Paris is the capital of France.',
'Page 2: It is a beautiful city.'
]);
This project is open to feature requests/suggestions, bug reports etc. via GitHub issues.
Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.
The SAP Cloud SDK for AI is released under the Apache License Version 2.0..
FAQs
LangChain clients based on the @sap-ai-sdk
The npm package @sap-ai-sdk/langchain receives a total of 0 weekly downloads. As such, @sap-ai-sdk/langchain popularity was classified as not popular.
We found that @sap-ai-sdk/langchain demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.