@latchway/langchain 0.0.0-bootstrap.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +7 -0
- package/README.md +21 -3
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -6
package/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Latchway JavaScript SDK
|
|
2
|
+
Copyright 2026 Latchway contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Latchway contributors.
|
|
5
|
+
|
|
6
|
+
The Code of Conduct is adapted from Contributor Covenant version 2.1,
|
|
7
|
+
licensed under the Creative Commons Attribution 4.0 International License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@latchway/langchain`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The LangChain.js adapter configures `ChatOpenAI` and `OpenAIEmbeddings` through
|
|
4
|
+
their underlying OpenAI client options. It does not introduce chains, agents,
|
|
5
|
+
graphs, memory, retrieval, or tool execution.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
```ts
|
|
8
|
+
import { createLatchwayChatOpenAI } from "@latchway/langchain";
|
|
9
|
+
|
|
10
|
+
const model = createLatchwayChatOpenAI({
|
|
11
|
+
latchway,
|
|
12
|
+
feature: "habit-assistant",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const message = await model.invoke("Summarize today");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The generated OpenAI-compatible model value is `latchway`; it is not a
|
|
19
|
+
physical model selection. Streaming, batching, tools, structured output,
|
|
20
|
+
cancellation, callbacks, and framework retries remain LangChain behavior over
|
|
21
|
+
the authenticated transport. Latchway correlation IDs are mirrored to the
|
|
22
|
+
underlying OpenAI client's conventional request-ID header without buffering
|
|
23
|
+
the response.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChatOpenAI, type ChatOpenAIFields, OpenAIEmbeddings, type OpenAIEmbeddingsParams } from "@langchain/openai";
|
|
2
|
+
export interface AuthenticatedTransport {
|
|
3
|
+
readonly gatewayURL: string;
|
|
4
|
+
fetchFor(feature: string, framework: Readonly<{
|
|
5
|
+
id: "langchain-js";
|
|
6
|
+
version: string;
|
|
7
|
+
}>): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
}
|
|
9
|
+
export type LatchwayChatOpenAIOptions = Omit<ChatOpenAIFields, "apiKey" | "configuration" | "model" | "modelName" | "openAIApiKey">;
|
|
10
|
+
export interface CreateLatchwayChatOpenAIOptions {
|
|
11
|
+
latchway: AuthenticatedTransport;
|
|
12
|
+
feature: string;
|
|
13
|
+
chatOptions?: LatchwayChatOpenAIOptions;
|
|
14
|
+
}
|
|
15
|
+
export type LatchwayEmbeddingsOptions = Omit<Partial<OpenAIEmbeddingsParams>, "model" | "modelName">;
|
|
16
|
+
export interface CreateLatchwayEmbeddingsOptions {
|
|
17
|
+
latchway: AuthenticatedTransport;
|
|
18
|
+
feature: string;
|
|
19
|
+
embeddingsOptions?: LatchwayEmbeddingsOptions;
|
|
20
|
+
}
|
|
21
|
+
export declare function createLatchwayChatOpenAI(options: CreateLatchwayChatOpenAIOptions): ChatOpenAI;
|
|
22
|
+
export declare function createLatchwayEmbeddings(options: CreateLatchwayEmbeddingsOptions): OpenAIEmbeddings;
|
|
23
|
+
export declare const LANGCHAIN_OPENAI_VERSION: string;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAM3B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,QAAQ,CAAC;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GAC3D,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxE;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,gBAAgB,EAChB,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,CACpE,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,OAAO,CAAC,sBAAsB,CAAC,EAC/B,OAAO,GAAG,WAAW,CACtB,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;CAC/C;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,UAAU,CAc7F;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,gBAAgB,CAenG;AAED,eAAO,MAAM,wBAAwB,QAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ChatOpenAI, OpenAIEmbeddings, } from "@langchain/openai";
|
|
2
|
+
import langchainOpenAIPackage from "@langchain/openai/package.json" with { type: "json" };
|
|
3
|
+
const frameworkVersion = langchainOpenAIPackage.version;
|
|
4
|
+
const placeholder = "latchway-managed-not-a-provider-secret";
|
|
5
|
+
export function createLatchwayChatOpenAI(options) {
|
|
6
|
+
const authenticatedFetch = options.latchway.fetchFor(options.feature, {
|
|
7
|
+
id: "langchain-js",
|
|
8
|
+
version: frameworkVersion,
|
|
9
|
+
});
|
|
10
|
+
return new ChatOpenAI({
|
|
11
|
+
...options.chatOptions,
|
|
12
|
+
apiKey: placeholder,
|
|
13
|
+
model: "latchway",
|
|
14
|
+
configuration: {
|
|
15
|
+
baseURL: `${options.latchway.gatewayURL}/v1`,
|
|
16
|
+
fetch: withProviderRequestID(authenticatedFetch),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function createLatchwayEmbeddings(options) {
|
|
21
|
+
const authenticatedFetch = options.latchway.fetchFor(options.feature, {
|
|
22
|
+
id: "langchain-js",
|
|
23
|
+
version: frameworkVersion,
|
|
24
|
+
});
|
|
25
|
+
return new OpenAIEmbeddings({
|
|
26
|
+
...options.embeddingsOptions,
|
|
27
|
+
apiKey: placeholder,
|
|
28
|
+
encodingFormat: "float",
|
|
29
|
+
model: "latchway",
|
|
30
|
+
configuration: {
|
|
31
|
+
baseURL: `${options.latchway.gatewayURL}/v1`,
|
|
32
|
+
fetch: withProviderRequestID(authenticatedFetch),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export const LANGCHAIN_OPENAI_VERSION = frameworkVersion;
|
|
37
|
+
function withProviderRequestID(fetch) {
|
|
38
|
+
return async (input, init) => aliasRequestID(await fetch(input, init));
|
|
39
|
+
}
|
|
40
|
+
function aliasRequestID(response) {
|
|
41
|
+
const requestID = response.headers.get("X-Latchway-Request-ID");
|
|
42
|
+
if (requestID === null || response.headers.has("X-Request-ID"))
|
|
43
|
+
return response;
|
|
44
|
+
const headers = new Headers(response.headers);
|
|
45
|
+
headers.set("X-Request-ID", requestID);
|
|
46
|
+
const aliased = new Response(response.body, {
|
|
47
|
+
status: response.status,
|
|
48
|
+
statusText: response.statusText,
|
|
49
|
+
headers,
|
|
50
|
+
});
|
|
51
|
+
preserveResponseLocation(aliased, response);
|
|
52
|
+
return aliased;
|
|
53
|
+
}
|
|
54
|
+
function preserveResponseLocation(target, source) {
|
|
55
|
+
Object.defineProperties(target, {
|
|
56
|
+
redirected: { value: source.redirected },
|
|
57
|
+
type: { value: source.type },
|
|
58
|
+
url: { value: source.url },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,sBAAsB,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1F,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,OAAO,CAAC;AACxD,MAAM,WAAW,GAAG,wCAAwC,CAAC;AAgC7D,MAAM,UAAU,wBAAwB,CAAC,OAAwC;IAC/E,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;QACpE,EAAE,EAAE,cAAc;QAClB,OAAO,EAAE,gBAAgB;KAC1B,CAAC,CAAC;IACH,OAAO,IAAI,UAAU,CAAC;QACpB,GAAG,OAAO,CAAC,WAAW;QACtB,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,UAAU;QACjB,aAAa,EAAE;YACb,OAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK;YAC5C,KAAK,EAAE,qBAAqB,CAAC,kBAAkB,CAAC;SACjD;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAwC;IAC/E,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;QACpE,EAAE,EAAE,cAA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MAAgB;IAClE,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QAC9B,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE;QACxC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE;QAC5B,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latchway/langchain",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Feature-bound Latchway transport adapter for LangChain.js OpenAI integrations",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24.19.0"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
6
13
|
"files": [
|
|
14
|
+
"dist",
|
|
7
15
|
"LICENSE",
|
|
16
|
+
"NOTICE",
|
|
8
17
|
"README.md"
|
|
9
18
|
],
|
|
10
19
|
"repository": {
|
|
@@ -13,8 +22,20 @@
|
|
|
13
22
|
"directory": "packages/langchain"
|
|
14
23
|
},
|
|
15
24
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@langchain/openai": "1.5.10",
|
|
35
|
+
"@latchway/client": "^1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.build.json",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
19
40
|
}
|
|
20
|
-
}
|
|
41
|
+
}
|