File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -126,10 +126,23 @@ function noStopSequencesNoMaxNumTokens(testCase)
126
126
end
127
127
128
128
function createOpenAIChatWithStreamFunc(testCase )
129
- sf = @(x )fprintf(" %s" , x );
130
- chat = openAIChat(ApiKey = " this-is-not-a-real-key" , StreamFun= sf );
129
+
130
+ function seen = sf(str )
131
+ persistent data ;
132
+ if isempty(data )
133
+ data = strings(1 , 0 );
134
+ end
135
+ % Append streamed text to an empty string array of length 1
136
+ data = [data , str ];
137
+ seen = data ;
138
+ end
139
+ chat = openAIChat(ApiKey = getenv(" OPENAI_KEY" ), StreamFun= @sf );
131
140
132
141
testCase .verifyWarningFree(@()generate(chat , " Hello world." ));
142
+ % Checking that persistent data, which is still stored in
143
+ % memory, is greater than 1. This would mean that the stream
144
+ % function has been called and streamed some text.
145
+ testCase .verifyGreaterThan(numel(sf(" " )), 1 );
133
146
end
134
147
135
148
function warningJSONResponseFormatGPT35(testCase )
You can’t perform that action at this time.
0 commit comments