Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(langchainjs): deprecate v0.1 support for security reasons #1328

Merged
merged 4 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/.changeset/cute-clouds-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arizeai/openinference-instrumentation-langchain": major
---

deprecate support for v0.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ lcInstrumentation.manuallyInstrument(CallbackManagerModule);
```

For more information on OpenTelemetry Node.js SDK, see the [OpenTelemetry Node.js SDK documentation](https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/).

## Deprecations

LangChain v0.1 was deprecated on 2025-03-02 due to security vulerabilities in the core package.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@
"@opentelemetry/instrumentation": "^0.46.0"
},
"peerDependencies": {
"@langchain/core": "^0.1.0 || ^0.2.0 || ^0.3.0"
"@langchain/core": "^0.2.0 || ^0.3.0"
},
"devDependencies": {
"@langchain/core": "^0.3.13",
"@langchain/coreV0.2": "npm:@langchain/core@^0.2.0",
"@langchain/coreV0.1": "npm:@langchain/core@^0.1.0",
"@langchain/openai": "^0.3.11",
"@langchain/openaiV0.2": "npm:@langchain/openai@^0.2.0",
"@langchain/openaiV0.1": "npm:@langchain/openai@^0.1.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.50.0",
"@opentelemetry/resources": "^1.25.1",
"@opentelemetry/sdk-trace-base": "^1.25.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type * as CallbackManagerModuleV02 from "@langchain/core/callbacks/manager";
import type * as CallbackManagerModuleV01 from "@langchain/coreV0.1/callbacks/manager";
import {
InstrumentationBase,
InstrumentationConfig,
Expand Down Expand Up @@ -27,9 +26,7 @@ export function isPatched() {
return _isOpenInferencePatched;
}

type CallbackManagerModule =
| typeof CallbackManagerModuleV01
| typeof CallbackManagerModuleV02;
type CallbackManagerModule = typeof CallbackManagerModuleV02;

/**
* An auto instrumentation class for LangChain that creates {@link https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md|OpenInference} Compliant spans for LangChain
Expand Down Expand Up @@ -121,24 +118,6 @@ export class LangChainInstrumentation extends InstrumentationBase<CallbackManage
);
args[0] = newInheritableHandlers;

return original.apply(this, args);
};
});
} else {
this._wrap(module.CallbackManager, "configure", (original) => {
return function (
this: typeof CallbackManagerModuleV01,
...args: Parameters<
(typeof CallbackManagerModuleV01.CallbackManager)["configure"]
>
) {
const handlers = args[0];
const newHandlers = addTracerToHandlers(
instrumentation.oiTracer,
handlers,
);
args[0] = newHandlers;

return original.apply(this, args);
};
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type * as CallbackManagerModuleV02 from "@langchain/core/callbacks/manager";
import type * as CallbackManagerModuleV01 from "@langchain/coreV0.1/callbacks/manager";
import { LangChainTracer } from "./tracer";
import { OITracer } from "@arizeai/openinference-core";

Expand All @@ -10,25 +9,15 @@ import { OITracer } from "@arizeai/openinference-core";
* @returns the callback handlers with the {@link LangChainTracer} added
*
* If the handlers are an array, we add the tracer to the array if it is not already present
*
* There are some slight differences in the CallbackHandler interface between V0.1 and v0.2
* So we have to cast our tracer to any to avoid type errors
* We support both versions and our tracer is compatible with either as it will extend the BaseTracer from the installed version which will be the same as the version of handlers passed in here
*/
export function addTracerToHandlers(
tracer: OITracer,
handlers?: CallbackManagerModuleV01.Callbacks,
): CallbackManagerModuleV01.Callbacks;
export function addTracerToHandlers(
tracer: OITracer,
handlers?: CallbackManagerModuleV02.Callbacks,
): CallbackManagerModuleV02.Callbacks;
export function addTracerToHandlers(
tracer: OITracer,
handlers?:
| CallbackManagerModuleV01.Callbacks
| CallbackManagerModuleV02.Callbacks,
): CallbackManagerModuleV01.Callbacks | CallbackManagerModuleV02.Callbacks {
handlers?: CallbackManagerModuleV02.Callbacks,
): CallbackManagerModuleV02.Callbacks {
if (handlers == null) {
return [new LangChainTracer(tracer)];
}
Expand Down
Loading