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: 7e395cb00a132236d1ad4dcde51371c84dc345e5
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: 64c2b8f33b8c314a4c85a3035865cb396958ede2
Choose a head ref
  • 17 commits
  • 28 files changed
  • 10 contributors

Commits on Jan 18, 2025

  1. release(core): 0.3.31 (#7548)

    jacoblee93 authored Jan 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a52fde3 View commit details
  2. fix(community): Updated Embeddings URL (#7545)

    Jacky3003 authored Jan 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    74c06a5 View commit details
  3. fix(community): make sure guardrailConfig can be added even with anth…

    …ropic models (#7542)
    madmed88 authored Jan 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9804d8f View commit details
  4. docs: Fix PGVectorStore import in install dependencies (TypeScript) e…

    …xample (#7533)
    bploetz authored Jan 18, 2025
    Copy the full SHA
    904dcad View commit details
  5. fix(community): Airtable url (#7532)

    eduardconstantin authored Jan 18, 2025
    Copy the full SHA
    e0e2fc9 View commit details
  6. docs: Fix typo in OpenAIModerationChain example (#7528)

    JonathanVelkeneers authored Jan 18, 2025
    Copy the full SHA
    9314ef1 View commit details
  7. docs: Resolves #7483, resolves #7274 (#7505)

    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    ucev and jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    e1c8212 View commit details
  8. docs: Rename auth method in IBM docs (#7524)

    FilipZmijewski authored Jan 18, 2025
    Copy the full SHA
    08f1a46 View commit details
  9. docs: correct misspelling (#7522)

    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    ucev and jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    900381a View commit details
  10. release(community): 0.3.25 (#7549)

    jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    f1dbe28 View commit details
  11. feat(azure-cosmosdb): add session context for a user mongodb (#7436)

    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    crisjc-e and jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    3a1131a View commit details
  12. release(azure-cosmosdb): 0.2.7 (#7550)

    jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    9518c50 View commit details
  13. fix(ci): Fix build (#7551)

    jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    1546a2e View commit details
  14. feat(anthropic): Add Anthropic PDF support (document type) in invoke (#…

    …7496)
    
    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    adhambadr and jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    94467fa View commit details
  15. release(anthropic): 0.3.12 (#7552)

    jacoblee93 authored Jan 18, 2025
    Copy the full SHA
    fca3d89 View commit details

Commits on Jan 20, 2025

  1. chore(core,langchain,community): Relax langsmith deps (#7556)

    jacoblee93 authored Jan 20, 2025
    Copy the full SHA
    b235062 View commit details
  2. release(community): 0.3.26 (#7557)

    jacoblee93 authored Jan 20, 2025
    Copy the full SHA
    64c2b8f View commit details
Showing with 247 additions and 59 deletions.
  1. +2 βˆ’2 docs/core_docs/docs/how_to/tool_calling_parallel.ipynb
  2. +2 βˆ’2 docs/core_docs/docs/how_to/tool_results_pass_to_model.ipynb
  3. +2 βˆ’3 docs/core_docs/docs/integrations/chat/ibm.ipynb
  4. +2 βˆ’2 docs/core_docs/docs/integrations/document_compressors/ibm.ipynb
  5. +2 βˆ’2 docs/core_docs/docs/integrations/llms/ibm.ipynb
  6. +2 βˆ’2 docs/core_docs/docs/integrations/text_embedding/ibm.ipynb
  7. +1 βˆ’1 docs/core_docs/docs/integrations/tools/google_calendar.mdx
  8. +1 βˆ’1 docs/core_docs/src/theme/VectorStoreTabs.js
  9. +1 βˆ’1 examples/package.json
  10. +52 βˆ’0 examples/src/models/chat/integration_anthropic_pdf.ts
  11. +13 βˆ’8 examples/src/tools/google_calendar.ts
  12. +2 βˆ’2 langchain-core/package.json
  13. +1 βˆ’1 langchain/package.json
  14. +1 βˆ’1 langchain/src/chains/openai_moderation.ts
  15. +1 βˆ’1 libs/langchain-anthropic/package.json
  16. +7 βˆ’0 libs/langchain-anthropic/src/utils/message_inputs.ts
  17. +1 βˆ’1 libs/langchain-azure-cosmosdb/package.json
  18. +78 βˆ’3 libs/langchain-azure-cosmosdb/src/chat_histories/mongodb.ts
  19. +53 βˆ’2 libs/langchain-azure-cosmosdb/src/tests/chat_histories/mongodb.int.test.ts
  20. +2 βˆ’2 libs/langchain-community/package.json
  21. +1 βˆ’1 libs/langchain-community/src/document_loaders/web/airtable.ts
  22. +1 βˆ’1 libs/langchain-community/src/embeddings/togetherai.ts
  23. +3 βˆ’3 libs/langchain-community/src/tools/google_calendar/base.ts
  24. +2 βˆ’2 libs/langchain-community/src/tools/google_calendar/commands/run-create-events.ts
  25. +2 βˆ’2 libs/langchain-community/src/tools/google_calendar/commands/run-view-events.ts
  26. +4 βˆ’4 libs/langchain-community/src/tools/tests/google_calendar.test.ts
  27. +0 βˆ’1 libs/langchain-community/src/utils/bedrock/index.ts
  28. +8 βˆ’8 yarn.lock
4 changes: 2 additions & 2 deletions docs/core_docs/docs/how_to/tool_calling_parallel.ipynb
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@
"});\n",
"\n",
"const multiplyTool = tool(async ({ a, b }) => {\n",
" return a + b;\n",
" return a * b;\n",
"}, {\n",
" name: \"multiply\",\n",
" description: \"Multiplies a and b\",\n",
@@ -220,4 +220,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 2 additions & 2 deletions docs/core_docs/docs/how_to/tool_results_pass_to_model.ipynb
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
":::\n",
"```\n",
"\n",
"Some models are capable of [**tool calling**](/docs/concepts/tool_calling) - generating arguments that conform to a specific user-provided schema. This guide will demonstrate how to use those tool cals to actually call a function and properly pass the results back to the model.\n",
"Some models are capable of [**tool calling**](/docs/concepts/tool_calling) - generating arguments that conform to a specific user-provided schema. This guide will demonstrate how to use those tool calls to actually call a function and properly pass the results back to the model.\n",
"\n",
"![](../../static/img/tool_invocation.png)\n",
"\n",
@@ -367,4 +367,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
5 changes: 2 additions & 3 deletions docs/core_docs/docs/integrations/chat/ibm.ipynb
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@
"| Class | Package | Local | Serializable | [PY support](https://python.langchain.com/docs/integrations/chat/ibm_watsonx/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [`ChatWatsonx`](https://api.js.langchain.com/classes/_langchain_community.chat_models_ibm.ChatWatsonx.html) | [@langchain/community](https://www.npmjs.com/package/@langchain/community) | ❌ | βœ… | βœ… | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/community?style=flat-square&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square&label=%20&) |\n",

"\n",
"### Model features\n",
"\n",
@@ -61,7 +60,7 @@
"export WATSONX_AI_BEARER_TOKEN=<YOUR-BEARER-TOKEN>\n",
"```\n",
"\n",
"#### CP4D authentication\n",
"#### IBM watsonx.ai software authentication\n",
"\n",
"```bash\n",
"export WATSONX_AI_AUTH_TYPE=cp4d\n",
@@ -104,7 +103,7 @@
"const instance = new WatsonxLLM(props);\n",
"```\n",
"\n",
"### CP4D authentication\n",
"### IBM watsonx.ai software authentication\n",
"\n",
"```typescript\n",
"import { WatsonxLLM } from \"@langchain/community/llms/ibm\";\n",
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@
"export WATSONX_AI_BEARER_TOKEN=<YOUR-BEARER-TOKEN>\n",
"```\n",
"\n",
"#### CP4D authentication\n",
"#### IBM watsonx.ai software authentication\n",
"\n",
"```bash\n",
"export WATSONX_AI_AUTH_TYPE=cp4d\n",
@@ -96,7 +96,7 @@
"const instance = new WatsonxLLM(props);\n",
"```\n",
"\n",
"### CP4D authentication\n",
"### IBM watsonx.ai software authentication\n",
"\n",
"```typescript\n",
"import { WatsonxLLM } from \"@langchain/community/llms/ibm\";\n",
4 changes: 2 additions & 2 deletions docs/core_docs/docs/integrations/llms/ibm.ipynb
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@
"export WATSONX_AI_BEARER_TOKEN=<YOUR-BEARER-TOKEN>\n",
"```\n",
"\n",
"#### CP4D authentication\n",
"#### IBM watsonx.ai software authentication\n",
"\n",
"```bash\n",
"export WATSONX_AI_AUTH_TYPE=cp4d\n",
@@ -99,7 +99,7 @@
"const instance = new WatsonxLLM(props);\n",
"```\n",
"\n",
"### CP4D authentication\n",
"### IBM watsonx.ai software authentication\n",
"\n",
"```typescript\n",
"import { WatsonxLLM } from \"@langchain/community/llms/ibm\";\n",
4 changes: 2 additions & 2 deletions docs/core_docs/docs/integrations/text_embedding/ibm.ipynb
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
"export WATSONX_AI_BEARER_TOKEN=<YOUR-BEARER-TOKEN>\n",
"```\n",
"\n",
"#### CP4D authentication\n",
"#### IBM watsonx.ai software authentication\n",
"\n",
"```bash\n",
"export WATSONX_AI_AUTH_TYPE=cp4d\n",
@@ -98,7 +98,7 @@
"const instance = new WatsonxEmbeddings(props);\n",
"```\n",
"\n",
"### CP4D authentication\n",
"### IBM watsonx.ai software authentication\n",
"\n",
"```typescript\n",
"import { WatsonxEmbeddings } from \"@langchain/community/embeddings/ibm\";\n",
2 changes: 1 addition & 1 deletion docs/core_docs/docs/integrations/tools/google_calendar.mdx
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ import IntegrationInstallTooltip from "@mdx_components/integration_install_toolt
<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai @langchain/core
npm install @langchain/openai @langchain/core @langchain/community @langchain/langgraph
```

<CodeBlock language="typescript">{ToolExample}</CodeBlock>
2 changes: 1 addition & 1 deletion docs/core_docs/src/theme/VectorStoreTabs.js
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ const ${vectorStoreVarName} = new MongoDBAtlasVectorSearch(embeddings, {
{
value: "PGVector",
label: "PGVector",
text: `import PGVectorStore from "@langchain/community/vectorstores/pgvector";
text: `import { PGVectorStore } from "@langchain/community/vectorstores/pgvector";
const ${vectorStoreVarName} = await PGVectorStore.initialize(embeddings, {})`,
dependencies: "@langchain/community",
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@
"ioredis": "^5.3.2",
"js-yaml": "^4.1.0",
"langchain": "workspace:*",
"langsmith": "^0.2.8",
"langsmith": ">=0.2.8 <0.4.0",
"mongodb": "^6.3.0",
"pg": "^8.11.0",
"pickleparser": "^0.2.1",
52 changes: 52 additions & 0 deletions examples/src/models/chat/integration_anthropic_pdf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ChatAnthropic } from "@langchain/anthropic";

import * as fs from "fs";

export const run = async () => {
const llm = new ChatAnthropic({
model: "claude-3-5-sonnet-20240620", // Only claude-3-5-sonnet-20240620 , claude-3-5-sonnet-20241022 as of Jan 2025 support PDF documents as in base64
});

// PDF needs to be in Base64.
const getLocalFile = async (path: string) => {
const localFile = await fs.readFileSync(path);
const base64File = localFile.toString("base64");
return base64File;
};

// Or remotely
const getRemoteFile = async (url: string) => {
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const base64File = Buffer.from(arrayBuffer).toString("base64");
return base64File;
};

const base64 = await getRemoteFile(
"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
);

const prompt = "Summarise the contents of this PDF";

const response = await llm.invoke([
{
role: "user",
content: [
{
type: "text",
text: prompt,
},
{
type: "document",
source: {
media_type: "application/pdf",
type: "base64",
data: base64,
},
},
],
},
]);
console.log(response.content);
return response.content;
};
21 changes: 13 additions & 8 deletions examples/src/tools/google_calendar.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { initializeAgentExecutorWithOptions } from "langchain/agents";
import { OpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { ChatOpenAI } from "@langchain/openai";
import { Calculator } from "@langchain/community/tools/calculator";
import {
GoogleCalendarCreateTool,
GoogleCalendarViewTool,
} from "@langchain/community/tools/google_calendar";

export async function run() {
const model = new OpenAI({
const model = new ChatOpenAI({
temperature: 0,
apiKey: process.env.OPENAI_API_KEY,
model: "gpt-4o-mini",
});

const googleCalendarParams = {
@@ -31,22 +32,26 @@ export async function run() {
new GoogleCalendarViewTool(googleCalendarParams),
];

const calendarAgent = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
verbose: true,
const calendarAgent = createReactAgent({
llm: model,
tools,
});

const createInput = `Create a meeting with John Doe next Friday at 4pm - adding to the agenda of it the result of 99 + 99`;

const createResult = await calendarAgent.invoke({ input: createInput });
const createResult = await calendarAgent.invoke({
messages: [{ role: "user", content: createInput }],
});
// Create Result {
// output: 'A meeting with John Doe on 29th September at 4pm has been created and the result of 99 + 99 has been added to the agenda.'
// }
console.log("Create Result", createResult);

const viewInput = `What meetings do I have this week?`;

const viewResult = await calendarAgent.invoke({ input: viewInput });
const viewResult = await calendarAgent.invoke({
messages: [{ role: "user", content: viewInput }],
});
// View Result {
// output: "You have no meetings this week between 8am and 8pm."
// }
4 changes: 2 additions & 2 deletions langchain-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langchain/core",
"version": "0.3.30",
"version": "0.3.31",
"description": "Core LangChain.js abstractions and schemas",
"type": "module",
"engines": {
@@ -38,7 +38,7 @@
"camelcase": "6",
"decamelize": "1.2.0",
"js-tiktoken": "^1.0.12",
"langsmith": "^0.2.8",
"langsmith": ">=0.2.8 <0.4.0",
"mustache": "^4.2.0",
"p-queue": "^6.6.2",
"p-retry": "4",
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
@@ -530,7 +530,7 @@
"js-tiktoken": "^1.0.12",
"js-yaml": "^4.1.0",
"jsonpointer": "^5.0.1",
"langsmith": "^0.2.8",
"langsmith": ">=0.2.8 <0.4.0",
"openapi-types": "^12.1.3",
"p-retry": "4",
"uuid": "^10.0.0",
2 changes: 1 addition & 1 deletion langchain/src/chains/openai_moderation.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export interface OpenAIModerationChainInput
* OpenAIModerationChainInput interface.
* @example
* ```typescript
* const moderation = new ChatOpenAIModerationChain({ throwError: true });
* const moderation = new OpenAIModerationChain({ throwError: true });
*
* const badString = "Bad naughty words from user";
*
2 changes: 1 addition & 1 deletion 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.11",
"version": "0.3.12",
"description": "Anthropic integrations for LangChain.js",
"type": "module",
"engines": {
7 changes: 7 additions & 0 deletions libs/langchain-anthropic/src/utils/message_inputs.ts
Original file line number Diff line number Diff line change
@@ -131,6 +131,13 @@ function _formatContent(content: MessageContent) {
source,
...(cacheControl ? { cache_control: cacheControl } : {}),
};
} else if (contentPart.type === "document") {
// PDF
return {
type: "document",
source: contentPart.source,
...(cacheControl ? { cache_control: cacheControl } : {}),
};
} else if (
textTypes.find((t) => t === contentPart.type) &&
"text" in contentPart
2 changes: 1 addition & 1 deletion libs/langchain-azure-cosmosdb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langchain/azure-cosmosdb",
"version": "0.2.6",
"version": "0.2.7",
"description": "Azure CosmosDB integration for LangChain.js",
"type": "module",
"engines": {
Loading