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: 39e1d98ab000e2eb10e9915f8a5ec6a2481d89b0
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: 1e26c3816bca4f36c12cf4ea1be11c93de5cd313
Choose a head ref

Commits on Jan 10, 2025

  1. Verified

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

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

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

Commits on Jan 11, 2025

  1. Copy the full SHA
    7b0dd1e View commit details
  2. Copy the full SHA
    c90f2e3 View commit details
  3. Copy the full SHA
    d4dd136 View commit details
  4. docs: Closes #7476 (#7506)

    Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
    ucev and jacoblee93 authored Jan 11, 2025
    Copy the full SHA
    9cd72c2 View commit details
  5. docs: Closes #7494 (#7504)

    Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
    ucev and jacoblee93 authored Jan 11, 2025
    Copy the full SHA
    46486be View commit details

Commits on Jan 13, 2025

  1. Copy the full SHA
    55215e4 View commit details
  2. Copy the full SHA
    dbda6d0 View commit details
  3. Copy the full SHA
    de63626 View commit details
  4. Copy the full SHA
    457c8f2 View commit details
  5. Copy the full SHA
    4daa673 View commit details
  6. Copy the full SHA
    ff0dc58 View commit details

Commits on Jan 18, 2025

  1. Copy the full SHA
    7e395cb View commit details
  2. Copy the full SHA
    a52fde3 View commit details
  3. Copy the full SHA
    74c06a5 View commit details
  4. Copy the full SHA
    9804d8f View commit details
  5. Copy the full SHA
    904dcad View commit details
  6. Copy the full SHA
    e0e2fc9 View commit details
  7. Copy the full SHA
    9314ef1 View commit details
  8. 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
  9. Copy the full SHA
    08f1a46 View commit details
  10. 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
  11. Fix weird issue

    jacoblee93 committed Jan 18, 2025
    Copy the full SHA
    1e26c38 View commit details
Showing with 401 additions and 114 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. +1 βˆ’1 docs/core_docs/docs/integrations/llms/huggingface_inference.mdx
  6. +2 βˆ’2 docs/core_docs/docs/integrations/llms/ibm.ipynb
  7. +2 βˆ’2 docs/core_docs/docs/integrations/text_embedding/ibm.ipynb
  8. +1 βˆ’1 docs/core_docs/docs/integrations/tools/google_calendar.mdx
  9. +1 βˆ’1 docs/core_docs/src/theme/VectorStoreTabs.js
  10. +5 βˆ’3 examples/src/document_loaders/notionapi.ts
  11. +13 βˆ’8 examples/src/tools/google_calendar.ts
  12. +1 βˆ’1 langchain-core/package.json
  13. +7 βˆ’9 langchain-core/src/callbacks/dispatch/web.ts
  14. +16 βˆ’2 langchain-core/src/language_models/chat_models.ts
  15. +86 βˆ’3 langchain-core/src/messages/tests/message_utils.test.ts
  16. +14 βˆ’8 langchain-core/src/messages/transformers.ts
  17. +4 βˆ’1 langchain-core/src/runnables/tests/runnable_stream_events_v2.test.ts
  18. +1 βˆ’1 langchain/package.json
  19. +1 βˆ’1 langchain/src/chains/openai_moderation.ts
  20. +1 βˆ’1 libs/langchain-community/package.json
  21. +1 βˆ’1 libs/langchain-community/src/document_loaders/web/airtable.ts
  22. +3 βˆ’1 libs/langchain-community/src/document_loaders/web/notionapi.ts
  23. +1 βˆ’1 libs/langchain-community/src/embeddings/togetherai.ts
  24. +3 βˆ’3 libs/langchain-community/src/tools/google_calendar/base.ts
  25. +2 βˆ’2 libs/langchain-community/src/tools/google_calendar/commands/run-create-events.ts
  26. +2 βˆ’2 libs/langchain-community/src/tools/google_calendar/commands/run-view-events.ts
  27. +4 βˆ’4 libs/langchain-community/src/tools/tests/google_calendar.test.ts
  28. +0 βˆ’1 libs/langchain-community/src/utils/bedrock/index.ts
  29. +1 βˆ’1 libs/langchain-google-common/package.json
  30. +1 βˆ’1 libs/langchain-google-common/src/chat_models.ts
  31. +115 βˆ’3 libs/langchain-google-common/src/tests/chat_models.test.ts
  32. +28 βˆ’1 libs/langchain-google-common/src/tests/llms.test.ts
  33. +9 βˆ’0 libs/langchain-google-common/src/tests/mock.ts
  34. +1 βˆ’2 libs/langchain-google-common/src/utils/failed_handler.ts
  35. +14 βˆ’3 libs/langchain-google-common/src/utils/gemini.ts
  36. +2 βˆ’2 libs/langchain-google-gauth/package.json
  37. +2 βˆ’2 libs/langchain-google-vertexai-web/package.json
  38. +2 βˆ’2 libs/langchain-google-vertexai/package.json
  39. +2 βˆ’2 libs/langchain-google-webauth/package.json
  40. +2 βˆ’2 libs/langchain-openai/package.json
  41. +6 βˆ’0 libs/langchain-openai/src/chat_models.ts
  42. +28 βˆ’16 libs/langchain-openai/src/tests/chat_models.int.test.ts
  43. +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",
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import UnifiedModelParamsTooltip from "@mdx_components/unified_model_params_tool
<UnifiedModelParamsTooltip></UnifiedModelParamsTooltip>

```typescript
import { HuggingFaceInference } from "langchain/llms/hf";
import { HuggingFaceInference } from "@langchain/community/llms/hf";

const model = new HuggingFaceInference({
model: "gpt2",
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",
8 changes: 5 additions & 3 deletions examples/src/document_loaders/notionapi.ts
Original file line number Diff line number Diff line change
@@ -12,10 +12,12 @@ const pageLoader = new NotionAPILoader({

const splitter = new RecursiveCharacterTextSplitter();

// A page contents is likely to be more than 1000 characters so it's split into multiple documents (important for vectorization)
const pageDocs = await pageLoader.loadAndSplit(splitter);
// Load the documents
const pageDocs = await pageLoader.load();
// Split the documents using the text splitter
const splitDocs = await splitter.splitDocuments(pageDocs);

console.log({ pageDocs });
console.log({ splitDocs });

// Loading a database (each row is a separate document with all properties as metadata)
const dbLoader = new NotionAPILoader({
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."
// }
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.28",
"version": "0.3.31",
"description": "Core LangChain.js abstractions and schemas",
"type": "module",
"engines": {
16 changes: 7 additions & 9 deletions langchain-core/src/callbacks/dispatch/web.ts
Original file line number Diff line number Diff line change
@@ -39,17 +39,11 @@ export async function dispatchCustomEvent(
payload: any,
config?: RunnableConfig
) {
const callbackManager = await getCallbackManagerForConfig(config);
const parentRunId = callbackManager?.getParentRunId();
// We want to get the callback manager for the parent run.
// This is a work-around for now to be able to dispatch adhoc events from
// within a tool or a lambda and have the metadata events associated
// with the parent run rather than have a new run id generated for each.
if (callbackManager === undefined || parentRunId === undefined) {
if (config === undefined) {
throw new Error(
[
"Unable to dispatch a custom event without a parent run id.",
"This function can only be called from within an existing run (e.g.,",
`"dispatchCustomEvent" can only be called from within an existing run (e.g.,`,
"inside a tool or a RunnableLambda).",
`\n\nIf you continue to see this error, please import from "@langchain/core/callbacks/dispatch/web"`,
"and explicitly pass in a config parameter.",
@@ -60,7 +54,11 @@ export async function dispatchCustomEvent(
].join(" ")
);
}
const callbackManager = await getCallbackManagerForConfig(config);
const parentRunId = callbackManager?.getParentRunId();
// We pass parent id as the current run id here intentionally since events dispatch
// from within things like RunnableLambda
await callbackManager.handleCustomEvent?.(name, payload, parentRunId);
if (callbackManager !== undefined && parentRunId !== undefined) {
await callbackManager.handleCustomEvent?.(name, payload, parentRunId);
}
}
18 changes: 16 additions & 2 deletions langchain-core/src/language_models/chat_models.ts
Original file line number Diff line number Diff line change
@@ -74,7 +74,18 @@ export type SerializedLLM = {
/**
* Represents the parameters for a base chat model.
*/
export type BaseChatModelParams = BaseLanguageModelParams;
export type BaseChatModelParams = BaseLanguageModelParams & {
/**
* Whether to disable streaming.
*
* If streaming is bypassed, then `stream()` will defer to
* `invoke()`.
*
* - If true, will always bypass streaming case.
* - If false (default), will always use streaming case if available.
*/
disableStreaming?: boolean;
};

/**
* Represents the call options for a base chat model.
@@ -152,6 +163,8 @@ export abstract class BaseChatModel<
// Only ever instantiated in main LangChain
lc_namespace = ["langchain", "chat_models", this._llmType()];

disableStreaming = false;

constructor(fields: BaseChatModelParams) {
super(fields);
}
@@ -220,7 +233,8 @@ export abstract class BaseChatModel<
// Subclass check required to avoid double callbacks with default implementation
if (
this._streamResponseChunks ===
BaseChatModel.prototype._streamResponseChunks
BaseChatModel.prototype._streamResponseChunks ||
this.disableStreaming
) {
yield this.invoke(input, options);
} else {
Loading