Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@langchain/aws

Package Overview
Dependencies
Maintainers
10
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/aws - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

10

dist/retrievers/bedrock.d.ts

@@ -1,2 +0,2 @@

import { BedrockAgentRuntimeClient, type BedrockAgentRuntimeClientConfig } from "@aws-sdk/client-bedrock-agent-runtime";
import { BedrockAgentRuntimeClient, type BedrockAgentRuntimeClientConfig, type SearchType, type RetrievalFilter } from "@aws-sdk/client-bedrock-agent-runtime";
import { BaseRetriever } from "@langchain/core/retrievers";

@@ -13,2 +13,4 @@ import { Document } from "@langchain/core/documents";

clientOptions?: BedrockAgentRuntimeClientConfig;
filter?: RetrievalFilter;
overrideSearchType?: SearchType;
}

@@ -41,3 +43,5 @@ /**

bedrockAgentRuntimeClient: BedrockAgentRuntimeClient;
constructor({ knowledgeBaseId, topK, clientOptions, region, }: AmazonKnowledgeBaseRetrieverArgs);
filter?: RetrievalFilter;
overrideSearchType?: SearchType;
constructor({ knowledgeBaseId, topK, clientOptions, region, filter, overrideSearchType, }: AmazonKnowledgeBaseRetrieverArgs);
/**

@@ -50,3 +54,3 @@ * Cleans the result text by replacing sequences of whitespace with a

cleanResult(resText: string): string;
queryKnowledgeBase(query: string, topK: number): Promise<Document<Record<string, any>>[] | {
queryKnowledgeBase(query: string, topK: number, filter?: RetrievalFilter, overrideSearchType?: SearchType): Promise<Document<Record<string, any>>[] | {
pageContent: string;

@@ -53,0 +57,0 @@ metadata: {

@@ -27,3 +27,3 @@ import { RetrieveCommand, BedrockAgentRuntimeClient, } from "@aws-sdk/client-bedrock-agent-runtime";

}
constructor({ knowledgeBaseId, topK = 10, clientOptions, region, }) {
constructor({ knowledgeBaseId, topK = 10, clientOptions, region, filter, overrideSearchType, }) {
super();

@@ -54,3 +54,17 @@ Object.defineProperty(this, "lc_namespace", {

});
Object.defineProperty(this, "filter", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "overrideSearchType", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.topK = topK;
this.filter = filter;
this.overrideSearchType = overrideSearchType;
this.bedrockAgentRuntimeClient = new BedrockAgentRuntimeClient({

@@ -72,3 +86,3 @@ region,

}
async queryKnowledgeBase(query, topK) {
async queryKnowledgeBase(query, topK, filter, overrideSearchType) {
const retrieveCommand = new RetrieveCommand({

@@ -82,2 +96,4 @@ knowledgeBaseId: this.knowledgeBaseId,

numberOfResults: topK,
overrideSearchType,
filter,
},

@@ -87,15 +103,38 @@ },

const retrieveResponse = await this.bedrockAgentRuntimeClient.send(retrieveCommand);
return (retrieveResponse.retrievalResults?.map((result) => ({
pageContent: this.cleanResult(result.content?.text || ""),
metadata: {
source: result.location?.s3Location?.uri,
score: result.score,
...result.metadata,
},
})) ?? []);
return (retrieveResponse.retrievalResults?.map((result) => {
let source;
switch (result.location?.type) {
case "CONFLUENCE":
source = result.location?.confluenceLocation?.url;
break;
case "S3":
source = result.location?.s3Location?.uri;
break;
case "SALESFORCE":
source = result.location?.salesforceLocation?.url;
break;
case "SHAREPOINT":
source = result.location?.sharePointLocation?.url;
break;
case "WEB":
source = result.location?.webLocation?.url;
break;
default:
source = result.location?.s3Location?.uri;
break;
}
return {
pageContent: this.cleanResult(result.content?.text || ""),
metadata: {
source,
score: result.score,
...result.metadata,
},
};
}) ?? []);
}
async _getRelevantDocuments(query) {
const docs = await this.queryKnowledgeBase(query, this.topK);
const docs = await this.queryKnowledgeBase(query, this.topK, this.filter, this.overrideSearchType);
return docs;
}
}
{
"name": "@langchain/aws",
"version": "0.0.5",
"version": "0.0.6",
"description": "LangChain AWS integration",

@@ -18,3 +18,3 @@ "type": "module",

"build": "yarn turbo:command build:internal --filter=@langchain/aws",
"build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking",
"build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking",
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",

@@ -43,3 +43,3 @@ "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs",

"dependencies": {
"@aws-sdk/client-bedrock-agent-runtime": "^3.583.0",
"@aws-sdk/client-bedrock-agent-runtime": "^3.616.0",
"@aws-sdk/client-bedrock-runtime": "^3.602.0",

@@ -52,5 +52,5 @@ "@aws-sdk/client-kendra": "^3.352.0",

"devDependencies": {
"@aws-sdk/types": "^3.598.0",
"@aws-sdk/types": "^3.609.0",
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/scripts": "~0.0.20",
"@langchain/standard-tests": "0.0.0",

@@ -73,3 +73,2 @@ "@smithy/types": "^3.2.0",

"jest-environment-node": "^29.6.4",
"langchain": "workspace:*",
"prettier": "^2.8.3",

@@ -76,0 +75,0 @@ "release-it": "^15.10.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc