File tree 2 files changed +16
-2
lines changed
langchain-core/src/language_models
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ export abstract class BaseLLM<
156
156
} ) ;
157
157
try {
158
158
for await ( const chunk of this . _streamResponseChunks (
159
- input . toString ( ) ,
159
+ prompt . toString ( ) ,
160
160
callOptions ,
161
161
runManagers ?. [ 0 ]
162
162
) ) {
Original file line number Diff line number Diff line change 1
1
/* eslint-disable no-promise-executor-return */
2
2
3
3
import { test } from "@jest/globals" ;
4
- import { FakeLLM } from "../../utils/testing/index.js" ;
4
+ import { FakeLLM , FakeStreamingLLM } from "../../utils/testing/index.js" ;
5
+ import { HumanMessagePromptTemplate } from "../../prompts/chat.js" ;
5
6
6
7
test ( "Test FakeLLM uses callbacks" , async ( ) => {
7
8
const model = new FakeLLM ( { } ) ;
@@ -40,3 +41,16 @@ test("Test FakeLLM uses callbacks with a cache", async () => {
40
41
expect ( response ) . toEqual ( response2 ) ;
41
42
expect ( response2 ) . toEqual ( acc ) ;
42
43
} ) ;
44
+
45
+ test ( "Test FakeStreamingLLM works when streaming through a prompt" , async ( ) => {
46
+ const prompt = HumanMessagePromptTemplate . fromTemplate ( "hello there {name}" ) ;
47
+ const model = new FakeStreamingLLM ( { } ) ;
48
+ const chain = prompt . pipe ( model ) ;
49
+ const stream = await chain . stream ( { name : "test" } ) ;
50
+ const chunks = [ ] ;
51
+ for await ( const chunk of stream ) {
52
+ chunks . push ( chunk ) ;
53
+ }
54
+ expect ( chunks . length ) . toBeGreaterThan ( 1 ) ;
55
+ expect ( chunks . join ( "" ) ) . toEqual ( "Human: hello there test" ) ;
56
+ } ) ;
You can’t perform that action at this time.
0 commit comments