Skip to content

Commit fd45bf3

Browse files
committed
feat: Support auto-streaming with langchain
1 parent ffeae51 commit fd45bf3

File tree

15 files changed

+1189
-47
lines changed

15 files changed

+1189
-47
lines changed

packages/langchain/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@
3939
"@sap-cloud-sdk/connectivity": "^4.2.0",
4040
"@sap-cloud-sdk/util": "^4.2.0",
4141
"uuid": "^13.0.0"
42+
},
43+
"devDependencies": {
44+
"@langchain/langgraph": "^1.0.7"
4245
}
4346
}

packages/langchain/src/openai/__snapshots__/chat.test.ts.snap

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,173 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3+
exports[`Chat client streaming has langchain handle disabling streaming via disableStreaming flag in stream 1`] = `
4+
{
5+
"id": [
6+
"langchain_core",
7+
"messages",
8+
"AIMessage",
9+
],
10+
"kwargs": {
11+
"additional_kwargs": {
12+
"function_call": undefined,
13+
"tool_calls": undefined,
14+
},
15+
"content": "The capital of France is Paris.",
16+
"invalid_tool_calls": [],
17+
"response_metadata": {
18+
"created": undefined,
19+
"finish_reason": undefined,
20+
"function_call": undefined,
21+
"id": undefined,
22+
"index": 0,
23+
"model": undefined,
24+
"object": undefined,
25+
"promptFilterResults": undefined,
26+
"tokenUsage": {
27+
"completionTokens": 0,
28+
"promptTokens": 0,
29+
"totalTokens": 0,
30+
},
31+
"tool_calls": undefined,
32+
},
33+
"tool_calls": [],
34+
"usage_metadata": {
35+
"input_tokens": 0,
36+
"output_tokens": 0,
37+
"total_tokens": 0,
38+
},
39+
},
40+
"lc": 1,
41+
"type": "constructor",
42+
}
43+
`;
44+
45+
exports[`Chat client streaming supports auto-streaming responses 1`] = `
46+
{
47+
"id": [
48+
"langchain_core",
49+
"messages",
50+
"AIMessageChunk",
51+
],
52+
"kwargs": {
53+
"additional_kwargs": {},
54+
"content": "The capital of France is Paris.",
55+
"id": undefined,
56+
"invalid_tool_calls": [],
57+
"response_metadata": {
58+
"completion": 0,
59+
"created": 1730125149,
60+
"finish_reason": "stop",
61+
"id": "chatcmpl-ANKsHIdjvozwuOGpGI6rygvwSJH0I",
62+
"index": 0,
63+
"model_name": "gpt-4o",
64+
"prompt": 0,
65+
"system_fingerprint": "fp_808245b034",
66+
"token_usage": {
67+
"completion_tokens": 7,
68+
"prompt_tokens": 14,
69+
"total_tokens": 21,
70+
},
71+
},
72+
"tool_call_chunks": [],
73+
"tool_calls": [],
74+
"usage_metadata": {
75+
"input_token_details": {},
76+
"input_tokens": 14,
77+
"output_token_details": {},
78+
"output_tokens": 7,
79+
"total_tokens": 21,
80+
},
81+
},
82+
"lc": 1,
83+
"type": "constructor",
84+
}
85+
`;
86+
87+
exports[`Chat client streaming supports auto-streaming responses via invoke-stream 1`] = `
88+
{
89+
"id": [
90+
"langchain_core",
91+
"messages",
92+
"AIMessageChunk",
93+
],
94+
"kwargs": {
95+
"additional_kwargs": {},
96+
"content": "The capital of France is Paris.",
97+
"id": undefined,
98+
"invalid_tool_calls": [],
99+
"response_metadata": {
100+
"completion": 0,
101+
"created": 1730125149,
102+
"finish_reason": "stop",
103+
"id": "chatcmpl-ANKsHIdjvozwuOGpGI6rygvwSJH0I",
104+
"index": 0,
105+
"model_name": "gpt-4o",
106+
"prompt": 0,
107+
"system_fingerprint": "fp_808245b034",
108+
"token_usage": {
109+
"completion_tokens": 7,
110+
"prompt_tokens": 14,
111+
"total_tokens": 21,
112+
},
113+
},
114+
"tool_call_chunks": [],
115+
"tool_calls": [],
116+
"usage_metadata": {
117+
"input_token_details": {},
118+
"input_tokens": 14,
119+
"output_token_details": {},
120+
"output_tokens": 7,
121+
"total_tokens": 21,
122+
},
123+
},
124+
"lc": 1,
125+
"type": "constructor",
126+
}
127+
`;
128+
129+
exports[`Chat client streaming supports disabling auto-streaming via disableStreaming flag 1`] = `
130+
{
131+
"id": [
132+
"langchain_core",
133+
"messages",
134+
"AIMessage",
135+
],
136+
"kwargs": {
137+
"additional_kwargs": {
138+
"function_call": undefined,
139+
"tool_calls": undefined,
140+
},
141+
"content": "The capital of France is Paris.",
142+
"invalid_tool_calls": [],
143+
"response_metadata": {
144+
"created": undefined,
145+
"finish_reason": undefined,
146+
"function_call": undefined,
147+
"id": undefined,
148+
"index": 0,
149+
"model": undefined,
150+
"object": undefined,
151+
"promptFilterResults": undefined,
152+
"tokenUsage": {
153+
"completionTokens": 0,
154+
"promptTokens": 0,
155+
"totalTokens": 0,
156+
},
157+
"tool_calls": undefined,
158+
},
159+
"tool_calls": [],
160+
"usage_metadata": {
161+
"input_tokens": 0,
162+
"output_tokens": 0,
163+
"total_tokens": 0,
164+
},
165+
},
166+
"lc": 1,
167+
"type": "constructor",
168+
}
169+
`;
170+
3171
exports[`Chat client streaming supports streaming responses 1`] = `
4172
{
5173
"id": [

0 commit comments

Comments
 (0)