-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathvitest.ts
More file actions
85 lines (83 loc) · 3.67 KB
/
Copy pathvitest.ts
File metadata and controls
85 lines (83 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { expect, describe, test } from "vitest";
import { BaseChatModelCallOptions } from "@langchain/core/language_models/chat_models";
import { AIMessageChunk } from "@langchain/core/messages";
import { RecordStringAny } from "../base.js";
import {
ChatModelIntegrationTestsFields,
ChatModelIntegrationTests as BaseChatModelIntegrationTests,
} from "./chat_models.js";
export abstract class ChatModelIntegrationTests<
CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
OutputMessageType extends AIMessageChunk = AIMessageChunk,
ConstructorArgs extends RecordStringAny = RecordStringAny
> extends BaseChatModelIntegrationTests<
CallOptions,
OutputMessageType,
ConstructorArgs
> {
constructor(
fields: ChatModelIntegrationTestsFields<
CallOptions,
OutputMessageType,
ConstructorArgs
>
) {
super(fields);
this.expect = expect;
}
/**
* Run all integration tests for the chat model.
*/
runTests(testName = "ChatModelIntegrationTests") {
describe(testName, () => {
test("should invoke model and return valid response", () =>
this.testInvoke());
test("should stream response tokens successfully", () =>
this.testStream());
test("should process multiple inputs in batch", () => this.testBatch());
test("should handle multi-message conversation", () =>
this.testConversation());
test("should return usage metadata for invoke", () =>
this.testUsageMetadata());
test("should return usage metadata for streaming", () =>
this.testUsageMetadataStreaming());
test("should handle tool message histories with string content", () =>
this.testToolMessageHistoriesStringContent());
test("should handle tool message histories with list content", () =>
this.testToolMessageHistoriesListContent());
test("should handle structured few shot examples", () =>
this.testStructuredFewShotExamples());
test("should work with structured output", () =>
this.testWithStructuredOutput());
test("should work with structured output including raw", () =>
this.testWithStructuredOutputIncludeRaw());
test("should bind tools with OpenAI formatted tools", () =>
this.testBindToolsWithOpenAIFormattedTools());
test("should bind tools with runnable tool-like objects", () =>
this.testBindToolsWithRunnableToolLike());
test("should cache complex message types", () =>
this.testCacheComplexMessageTypes());
test("should stream tokens with tool calls", () =>
this.testStreamTokensWithToolCalls());
test("should use tool use AI message in conversation", () =>
this.testModelCanUseToolUseAIMessage());
test("should use tool use AI message with streaming", () =>
this.testModelCanUseToolUseAIMessageWithStreaming());
test("should invoke model with more complex tools", () =>
this.testInvokeMoreComplexTools());
test("should handle parallel tool calling", () =>
this.testParallelToolCalling());
test("should accept structured tool params schema", () =>
this.testModelCanAcceptStructuredToolParamsSchema());
test("should stream tools successfully", () => this.testStreamTools());
test("should handle standard text content blocks", () =>
this.testStandardTextContentBlocks());
test("should handle standard image content blocks", () =>
this.testStandardImageContentBlocks());
test("should handle standard audio content blocks", () =>
this.testStandardAudioContentBlocks());
test("should handle standard file content blocks", () =>
this.testStandardFileContentBlocks());
});
}
}