@langchain/xai 0.0.3 → 0.1.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/dist/chat_models.cjs +5 -5
- package/dist/chat_models.d.ts +8 -8
- package/dist/chat_models.js +6 -6
- package/package.json +8 -8
package/dist/chat_models.cjs
CHANGED
|
@@ -329,7 +329,7 @@ const openai_1 = require("@langchain/openai");
|
|
|
329
329
|
*
|
|
330
330
|
* <br />
|
|
331
331
|
*/
|
|
332
|
-
class ChatXAI extends openai_1.
|
|
332
|
+
class ChatXAI extends openai_1.ChatOpenAICompletions {
|
|
333
333
|
static lc_name() {
|
|
334
334
|
return "ChatXAI";
|
|
335
335
|
}
|
|
@@ -411,10 +411,10 @@ class ChatXAI extends openai_1.ChatOpenAI {
|
|
|
411
411
|
}
|
|
412
412
|
return super.completionWithRetry(newRequest, options);
|
|
413
413
|
}
|
|
414
|
-
|
|
414
|
+
_convertCompletionsDeltaToBaseMessageChunk(
|
|
415
415
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
416
416
|
delta, rawResponse, defaultRole) {
|
|
417
|
-
const messageChunk = super.
|
|
417
|
+
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
|
|
418
418
|
// Make concatenating chunks work without merge warning
|
|
419
419
|
if (!rawResponse.choices[0]?.finish_reason) {
|
|
420
420
|
delete messageChunk.response_metadata.usage;
|
|
@@ -425,8 +425,8 @@ class ChatXAI extends openai_1.ChatOpenAI {
|
|
|
425
425
|
}
|
|
426
426
|
return messageChunk;
|
|
427
427
|
}
|
|
428
|
-
|
|
429
|
-
const langChainMessage = super.
|
|
428
|
+
_convertCompletionsMessageToBaseMessage(message, rawResponse) {
|
|
429
|
+
const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
|
|
430
430
|
langChainMessage.additional_kwargs.reasoning_content =
|
|
431
431
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
432
432
|
message.reasoning_content;
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
|
|
1
|
+
import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
2
2
|
import { BaseChatModelCallOptions, BindToolsInput, LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
|
|
3
3
|
import { Serialized } from "@langchain/core/load/serializable";
|
|
4
4
|
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
5
5
|
import { Runnable } from "@langchain/core/runnables";
|
|
6
6
|
import { InteropZodType } from "@langchain/core/utils/types";
|
|
7
|
-
import { type OpenAICoreRequestOptions, type OpenAIClient,
|
|
7
|
+
import { type OpenAICoreRequestOptions, type OpenAIClient, OpenAIToolChoice, ChatOpenAICompletions } from "@langchain/openai";
|
|
8
8
|
type ChatXAIToolType = BindToolsInput | OpenAIClient.ChatCompletionTool;
|
|
9
9
|
export interface ChatXAICallOptions extends BaseChatModelCallOptions {
|
|
10
10
|
headers?: Record<string, string>;
|
|
@@ -374,7 +374,7 @@ export interface ChatXAIInput extends BaseChatModelParams {
|
|
|
374
374
|
*
|
|
375
375
|
* <br />
|
|
376
376
|
*/
|
|
377
|
-
export declare class ChatXAI extends
|
|
377
|
+
export declare class ChatXAI extends ChatOpenAICompletions<ChatXAICallOptions> {
|
|
378
378
|
static lc_name(): string;
|
|
379
379
|
_llmType(): string;
|
|
380
380
|
get lc_secrets(): {
|
|
@@ -387,14 +387,14 @@ export declare class ChatXAI extends ChatOpenAI<ChatXAICallOptions> {
|
|
|
387
387
|
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
388
388
|
completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsStreaming, options?: OpenAICoreRequestOptions): Promise<AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>>;
|
|
389
389
|
completionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming, options?: OpenAICoreRequestOptions): Promise<OpenAIClient.Chat.Completions.ChatCompletion>;
|
|
390
|
-
protected
|
|
391
|
-
protected
|
|
392
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
393
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
390
|
+
protected _convertCompletionsDeltaToBaseMessageChunk(delta: Record<string, any>, rawResponse: OpenAIClient.ChatCompletionChunk, defaultRole?: "function" | "user" | "system" | "developer" | "assistant" | "tool"): AIMessageChunk;
|
|
391
|
+
protected _convertCompletionsMessageToBaseMessage(message: OpenAIClient.ChatCompletionMessage, rawResponse: OpenAIClient.ChatCompletion): BaseMessage;
|
|
392
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
393
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
394
394
|
raw: BaseMessage;
|
|
395
395
|
parsed: RunOutput;
|
|
396
396
|
}>;
|
|
397
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
397
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
398
398
|
raw: BaseMessage;
|
|
399
399
|
parsed: RunOutput;
|
|
400
400
|
}>;
|
package/dist/chat_models.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getEnvironmentVariable } from "@langchain/core/utils/env";
|
|
2
|
-
import {
|
|
2
|
+
import { ChatOpenAICompletions, } from "@langchain/openai";
|
|
3
3
|
/**
|
|
4
4
|
* xAI chat model integration.
|
|
5
5
|
*
|
|
@@ -326,7 +326,7 @@ import { ChatOpenAI, } from "@langchain/openai";
|
|
|
326
326
|
*
|
|
327
327
|
* <br />
|
|
328
328
|
*/
|
|
329
|
-
export class ChatXAI extends
|
|
329
|
+
export class ChatXAI extends ChatOpenAICompletions {
|
|
330
330
|
static lc_name() {
|
|
331
331
|
return "ChatXAI";
|
|
332
332
|
}
|
|
@@ -408,10 +408,10 @@ export class ChatXAI extends ChatOpenAI {
|
|
|
408
408
|
}
|
|
409
409
|
return super.completionWithRetry(newRequest, options);
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
_convertCompletionsDeltaToBaseMessageChunk(
|
|
412
412
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
413
413
|
delta, rawResponse, defaultRole) {
|
|
414
|
-
const messageChunk = super.
|
|
414
|
+
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
|
|
415
415
|
// Make concatenating chunks work without merge warning
|
|
416
416
|
if (!rawResponse.choices[0]?.finish_reason) {
|
|
417
417
|
delete messageChunk.response_metadata.usage;
|
|
@@ -422,8 +422,8 @@ export class ChatXAI extends ChatOpenAI {
|
|
|
422
422
|
}
|
|
423
423
|
return messageChunk;
|
|
424
424
|
}
|
|
425
|
-
|
|
426
|
-
const langChainMessage = super.
|
|
425
|
+
_convertCompletionsMessageToBaseMessage(message, rawResponse) {
|
|
426
|
+
const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
|
|
427
427
|
langChainMessage.additional_kwargs.reasoning_content =
|
|
428
428
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
429
|
message.reasoning_content;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/xai",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "xAI integration for LangChain.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "yarn turbo:command build:internal --filter=@langchain/xai",
|
|
18
18
|
"build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
|
|
19
19
|
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
20
|
-
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
20
|
+
"lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
21
21
|
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
22
22
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
23
23
|
"clean": "rm -rf .turbo dist/",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"author": "LangChain",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@langchain/openai": "^0.
|
|
38
|
+
"@langchain/openai": "^0.6.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@langchain/core": ">=0.3.58 <0.4.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@jest/globals": "^29.5.0",
|
|
45
|
-
"@langchain/core": "
|
|
46
|
-
"@langchain/openai": "
|
|
45
|
+
"@langchain/core": "0.3.62",
|
|
46
|
+
"@langchain/openai": "^0.6.0",
|
|
47
47
|
"@langchain/scripts": ">=0.1.0 <0.2.0",
|
|
48
48
|
"@langchain/standard-tests": "0.0.0",
|
|
49
49
|
"@swc/core": "^1.3.90",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
54
54
|
"@typescript-eslint/parser": "^6.12.0",
|
|
55
55
|
"dotenv": "^16.3.1",
|
|
56
|
-
"dpdm": "^3.
|
|
56
|
+
"dpdm": "^3.14.0",
|
|
57
57
|
"eslint": "^8.33.0",
|
|
58
58
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
59
59
|
"eslint-config-prettier": "^8.6.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"release-it": "^18.1.2",
|
|
67
67
|
"rollup": "^4.5.2",
|
|
68
68
|
"ts-jest": "^29.1.0",
|
|
69
|
-
"typescript": "
|
|
69
|
+
"typescript": "~5.8.3",
|
|
70
70
|
"zod": "^3.25.32"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
@@ -91,4 +91,4 @@
|
|
|
91
91
|
"index.d.ts",
|
|
92
92
|
"index.d.cts"
|
|
93
93
|
]
|
|
94
|
-
}
|
|
94
|
+
}
|