Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: langchain-ai/langchainjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 70e10a9360fb8d06013c0055a81b005a91528aea
Choose a base ref
...
head repository: langchain-ai/langchainjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ed1d8c283ed351d6d8dd3661de7077a68b0d6acc
Choose a head ref
  • 19 commits
  • 40 files changed
  • 8 contributors

Commits on Feb 21, 2025

  1. release(community): 0.3.32 (#7730)

    jacoblee93 authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    df0212b View commit details
  2. release(google-vertex): 0.2.0 (#7731)

    jacoblee93 authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d303e90 View commit details

Commits on Feb 24, 2025

  1. docs: Fix broken link (#7743)

    jacoblee93 authored Feb 24, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5284571 View commit details
  2. release(google-genai): Release 0.1.9 (#7748)

    jacoblee93 authored Feb 24, 2025
    Copy the full SHA
    4f7b157 View commit details
  3. feat(anthropic): Support claude 3.7 sonnet & extended thinking (#7750)

    benjamincburns authored Feb 24, 2025
    Copy the full SHA
    ae335a3 View commit details
  4. release(anthropic): 0.3.14

    benjamincburns committed Feb 24, 2025
    Copy the full SHA
    38d0ab8 View commit details
  5. release(anthropic): 0.3.14 (#7751)

    benjamincburns authored Feb 24, 2025
    Copy the full SHA
    370629b View commit details

Commits on Feb 27, 2025

  1. fix(pinecone): Update Pinecone SDK to 5.0.0, make peer dep (#7767)

    jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    eca902e View commit details
  2. release(pinecone): 0.2.0 (#7772)

    jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    dd68043 View commit details
  3. docs: Adds missing redirect (#7759)

    jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    cdb5d2d View commit details
  4. fix(core): don't create empty text content blocks (#7769)

    benjamincburns authored Feb 27, 2025
    Copy the full SHA
    1f57087 View commit details
  5. fix(community): usage error returned by Zhipuai streaming data was mi…

    …ssing tokens-related information (#7745)
    mmdapl authored Feb 27, 2025
    Copy the full SHA
    b820cbb View commit details
  6. fix(core): Skip delete operation if not necessary during incremental …

    …index (#7734)
    weakit authored Feb 27, 2025
    Copy the full SHA
    5f805b2 View commit details
  7. fix(google-genai): Fix Google Genai usage token (#7733)

    beowulf11 authored Feb 27, 2025
    Copy the full SHA
    79467fb View commit details
  8. fix(core): add artifact to ToolMessage and ToolMessageChunk for Remot…

    …eRunnable (#7763)
    
    Co-authored-by: Arnau Castells <acastells@semic.es>
    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    3 people authored Feb 27, 2025
    Copy the full SHA
    60e5950 View commit details
  9. fix(deepseek): wrong home link for @langchain/deepseek (#7754)

    AllenFang authored Feb 27, 2025
    Copy the full SHA
    efed92d View commit details
  10. release(google-genai): 0.1.10 (#7773)

    jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    1bf36c9 View commit details
  11. release(core): 0.3.41 (#7774)

    jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    d07f6da View commit details
  12. feat(community): Support google cloud storage document loader (#7740)

    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    AllenFang and jacoblee93 authored Feb 27, 2025
    Copy the full SHA
    ed1d8c2 View commit details
Showing with 617 additions and 81 deletions.
  1. +33 βˆ’0 docs/core_docs/docs/integrations/document_loaders/web_loaders/google_cloud_storage.mdx
  2. +1 βˆ’1 docs/core_docs/docs/integrations/retrievers/self_query/pinecone.ipynb
  3. +1 βˆ’1 docs/core_docs/docs/integrations/text_embedding/pinecone.ipynb
  4. +2 βˆ’2 docs/core_docs/docs/integrations/vectorstores/pinecone.ipynb
  5. +12 βˆ’0 docs/core_docs/vercel.json
  6. +1 βˆ’1 examples/package.json
  7. +17 βˆ’0 examples/src/document_loaders/google_cloud_storage.ts
  8. +1 βˆ’1 langchain-core/package.json
  9. +6 βˆ’3 langchain-core/src/indexing/base.ts
  10. +6 βˆ’0 langchain-core/src/messages/base.ts
  11. +2 βˆ’0 langchain-core/src/runnables/remote.ts
  12. +2 βˆ’2 libs/langchain-anthropic/package.json
  13. +44 βˆ’1 libs/langchain-anthropic/src/chat_models.ts
  14. +162 βˆ’0 libs/langchain-anthropic/src/tests/chat_models.int.test.ts
  15. +4 βˆ’0 libs/langchain-anthropic/src/types.ts
  16. +21 βˆ’0 libs/langchain-anthropic/src/utils/message_inputs.ts
  17. +40 βˆ’2 libs/langchain-anthropic/src/utils/message_outputs.ts
  18. +4 βˆ’0 libs/langchain-community/.gitignore
  19. +1 βˆ’0 libs/langchain-community/langchain.config.js
  20. +15 βˆ’2 libs/langchain-community/package.json
  21. +3 βˆ’2 libs/langchain-community/src/chat_models/zhipuai.ts
  22. +104 βˆ’0 libs/langchain-community/src/document_loaders/web/google_cloud_storage.ts
  23. +1 βˆ’0 libs/langchain-community/src/load/import_map.ts
  24. +1 βˆ’1 libs/langchain-community/src/vectorstores/pinecone.ts
  25. +1 βˆ’1 libs/langchain-deepseek/package.json
  26. +1 βˆ’1 libs/langchain-google-common/package.json
  27. +2 βˆ’2 libs/langchain-google-gauth/package.json
  28. +1 βˆ’1 libs/langchain-google-genai/package.json
  29. +7 βˆ’7 libs/langchain-google-genai/src/chat_models.ts
  30. +2 βˆ’2 libs/langchain-google-vertexai-web/package.json
  31. +2 βˆ’2 libs/langchain-google-vertexai/package.json
  32. +4 βˆ’2 libs/langchain-google-vertexai/src/tests/chat_models.int.test.ts
  33. +2 βˆ’2 libs/langchain-google-webauth/package.json
  34. +2 βˆ’2 libs/langchain-pinecone/README.md
  35. +4 βˆ’3 libs/langchain-pinecone/package.json
  36. +7 βˆ’6 libs/langchain-pinecone/src/embeddings.ts
  37. +2 βˆ’2 libs/langchain-pinecone/src/tests/embeddings.int.test.ts
  38. +2 βˆ’2 libs/langchain-pinecone/src/tests/vectorstores.int.test.ts
  39. +18 βˆ’4 libs/langchain-pinecone/src/vectorstores.ts
  40. +76 βˆ’23 yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
hide_table_of_contents: true
sidebar_class_name: node-only
---

# Google Cloud Storage

:::tip Compatibility
Only available on Node.js.
:::

This covers how to load a Google Cloud Storage File into LangChain documents.

## Setup

To use this loader, you'll need to have Unstructured already set up and ready to use at an available URL endpoint. It can also be configured to run locally.

See the docs [here](/docs/integrations/document_loaders/file_loaders/unstructured) for information on how to do that.

You'll also need to install the official Google Cloud Storage SDK:

```bash npm2yarn
npm install @langchain/community @langchain/core @google-cloud/storage
```

## Usage

Once Unstructured is configured, you can use the Google Cloud Storage loader to load files and then convert them into a Document.

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/document_loaders/google_cloud_storage.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@
"\n",
"The vector store lives in the `@langchain/pinecone` package. You'll also need to install the `langchain` package to import the main `SelfQueryRetriever` class.\n",
"\n",
"The official Pinecone SDK (`@pinecone-database/pinecone`) is automatically installed as a dependency of `@langchain/pinecone`, but you may wish to install it independently as well.\n",
"You will also need to install the official Pinecone SDK (`@pinecone-database/pinecone@5`).\n",
"\n",
"For this example, we'll also use OpenAI embeddings, so you'll need to install the `@langchain/openai` package and [obtain an API key](https://platform.openai.com):\n",
"\n",
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
"\n",
"<Npm2Yarn>\n",
" @langchain/pinecone @langchain/core\n",
" @langchain/pinecone @langchain/core @pinecone-database/pinecone@5\n",
"</Npm2Yarn>\n",
"```"
]
4 changes: 2 additions & 2 deletions docs/core_docs/docs/integrations/vectorstores/pinecone.ipynb
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
"\n",
"<Npm2Yarn>\n",
" @langchain/pinecone @langchain/openai @langchain/core @pinecone-database/pinecone \n",
" @langchain/pinecone @langchain/openai @langchain/core @pinecone-database/pinecone@5\n",
"</Npm2Yarn>\n",
"```\n",
"\n",
@@ -363,4 +363,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
12 changes: 12 additions & 0 deletions docs/core_docs/vercel.json
Original file line number Diff line number Diff line change
@@ -100,6 +100,18 @@
{
"source": "/docs/modules/model_io/prompts/quick_start/",
"destination": "/docs/concepts/prompt_templates"
},
{
"source": "/docs/modules/model_io/prompts(/?)",
"destination": "/docs/concepts/prompt_templates"
},
{
"source": "/docs/guides/expression_language/cookbook(/?)",
"destination": "/docs/how_to/sequence"
},
{
"source": "/docs/modules/model_io/models(/?)",
"destination": "/docs/integrations/chat/"
}
]
}
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@
"@langchain/yandex": "workspace:*",
"@layerup/layerup-security": "^1.5.12",
"@opensearch-project/opensearch": "^2.2.0",
"@pinecone-database/pinecone": "^4.0.0",
"@pinecone-database/pinecone": "^5.0.2",
"@planetscale/database": "^1.8.0",
"@prisma/client": "^4.11.0",
"@qdrant/js-client-rest": "^1.9.0",
17 changes: 17 additions & 0 deletions examples/src/document_loaders/google_cloud_storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { GoogleCloudStorageLoader } from "@langchain/community/document_loaders/web/google_cloud_storage";

const loader = new GoogleCloudStorageLoader({
bucket: "my-bucket-123",
file: "path/to/file.pdf",
storageOptions: {
keyFilename: "/path/to/keyfile.json",
},
unstructuredLoaderOptions: {
apiUrl: "http://localhost:8000/general/v0/general",
apiKey: "", // this will be soon required
},
});

const docs = await loader.load();

console.log(docs);
2 changes: 1 addition & 1 deletion langchain-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langchain/core",
"version": "0.3.40",
"version": "0.3.41",
"description": "Core LangChain.js abstractions and schemas",
"type": "module",
"engines": {
9 changes: 6 additions & 3 deletions langchain-core/src/indexing/base.ts
Original file line number Diff line number Diff line change
@@ -348,9 +348,12 @@ export async function index(args: IndexArgs): Promise<IndexingResult> {
before: indexStartDt,
groupIds: sourceIds,
});
await vectorStore.delete({ ids: uidsToDelete });
await recordManager.deleteKeys(uidsToDelete);
numDeleted += uidsToDelete.length;

if (uidsToDelete.length > 0) {
await vectorStore.delete({ ids: uidsToDelete });
await recordManager.deleteKeys(uidsToDelete);
numDeleted += uidsToDelete.length;
}
}
}

6 changes: 6 additions & 0 deletions langchain-core/src/messages/base.ts
Original file line number Diff line number Diff line change
@@ -107,6 +107,9 @@ export function mergeContent(
): MessageContent {
// If first content is a string
if (typeof firstContent === "string") {
if (firstContent === "") {
return secondContent;
}
if (typeof secondContent === "string") {
return firstContent + secondContent;
} else {
@@ -121,6 +124,9 @@ export function mergeContent(
]
);
} else {
if (secondContent === "") {
return firstContent;
}
// Otherwise, add the second content as a new element of the list
return [...firstContent, { type: "text", text: secondContent }];
}
2 changes: 2 additions & 0 deletions langchain-core/src/runnables/remote.ts
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ function revive(obj: any): any {
content: obj.content,
tool_call_id: obj.tool_call_id,
status: obj.status,
artifact: obj.artifact,
});
}
if (obj.type === "AIMessage" || obj.type === "ai") {
@@ -121,6 +122,7 @@ function revive(obj: any): any {
content: obj.content,
tool_call_id: obj.tool_call_id,
status: obj.status,
artifact: obj.artifact,
});
}
if (obj.type === "AIMessageChunk") {
4 changes: 2 additions & 2 deletions libs/langchain-anthropic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langchain/anthropic",
"version": "0.3.13",
"version": "0.3.14",
"description": "Anthropic integrations for LangChain.js",
"type": "module",
"engines": {
@@ -35,7 +35,7 @@
"author": "LangChain",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "^0.36.3",
"@anthropic-ai/sdk": "^0.37.0",
"fast-xml-parser": "^4.4.1",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.22.4"
45 changes: 44 additions & 1 deletion libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ import {
AnthropicMessageStreamEvent,
AnthropicRequestOptions,
AnthropicStreamingMessageCreateParams,
AnthropicThinkingConfigParam,
AnthropicToolChoice,
ChatAnthropicToolType,
} from "./types.js";
@@ -88,6 +89,12 @@ function _documentsInParams(
return false;
}

function _thinkingInParams(
params: AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams
): boolean {
return !!(params.thinking && params.thinking.type === "enabled");
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isAnthropicTool(tool: any): tool is Anthropic.Messages.Tool {
return "input_schema" in tool;
@@ -173,6 +180,11 @@ export interface AnthropicInput {
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
createClient?: (options: ClientOptions) => any;

/**
* Options for extended thinking.
*/
thinking?: AnthropicThinkingConfigParam;
}

/**
@@ -631,6 +643,8 @@ export class ChatAnthropicMessages<

clientOptions: ClientOptions;

thinking: AnthropicThinkingConfigParam = { type: "disabled" };

// Used for non-streaming requests
protected batchClient: Anthropic;

@@ -680,6 +694,8 @@ export class ChatAnthropicMessages<
this.streaming = fields?.streaming ?? false;
this.streamUsage = fields?.streamUsage ?? this.streamUsage;

this.thinking = fields?.thinking ?? this.thinking;

this.createClient =
fields?.createClient ??
((options: ClientOptions) => new Anthropic(options));
@@ -766,6 +782,30 @@ export class ChatAnthropicMessages<
| Anthropic.Messages.ToolChoiceTool
| undefined = handleToolChoice(options?.tool_choice);

if (this.thinking.type === "enabled") {
if (this.topK !== -1) {
throw new Error("topK is not supported when thinking is enabled");
}
if (this.topP !== -1) {
throw new Error("topP is not supported when thinking is enabled");
}
if (this.temperature !== 1) {
throw new Error(
"temperature is not supported when thinking is enabled"
);
}

return {
model: this.model,
stop_sequences: options?.stop ?? this.stopSequences,
stream: this.streaming,
max_tokens: this.maxTokens,
tools: this.formatStructuredToolToAnthropic(options?.tools),
tool_choice,
thinking: this.thinking,
...this.invocationKwargs,
};
}
return {
model: this.model,
temperature: this.temperature,
@@ -776,6 +816,7 @@ export class ChatAnthropicMessages<
max_tokens: this.maxTokens,
tools: this.formatStructuredToolToAnthropic(options?.tools),
tool_choice,
thinking: this.thinking,
...this.invocationKwargs,
};
}
@@ -811,7 +852,9 @@ export class ChatAnthropicMessages<
stream: true,
} as const;
const coerceContentToString =
!_toolsInParams(payload) && !_documentsInParams(payload);
!_toolsInParams(payload) &&
!_documentsInParams(payload) &&
!_thinkingInParams(payload);

const stream = await this.createStreamWithRetry(payload, {
headers: options.headers,
Loading