File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -142,3 +142,9 @@ export class OpenAIModelHandler extends GeneralModelHandler<OpenAIModelSettings>
142
142
return functionArguments || null ;
143
143
} ;
144
144
}
145
+
146
+ /** Used for unit testing */
147
+ // eslint-disable-next-line no-underscore-dangle
148
+ export const _private = {
149
+ wrapInOpenaiError,
150
+ } ;
Original file line number Diff line number Diff line change
1
+ import { describe , expect , test } from 'vitest' ;
2
+
3
+ import { DESCRIPTION_LENGTH_ERROR_LOG_MESSAGE , NonRetryableOpenaiAPIError } from '../../../src/errors' ;
4
+ import { _private } from '../../../src/models/openai' ;
5
+ import { LangchainError } from '../../../src/types/langchain-types' ;
6
+
7
+ const { wrapInOpenaiError } = _private ;
8
+
9
+ describe ( 'wrapInOpenaiError' , ( ) => {
10
+ test ( 'should return help error message for "too long function description" error' , ( ) => {
11
+ const error = new Error ( ) as LangchainError ;
12
+ error . error = { message : "'blah blah too long blah' is too long - 'functions.0.description'" } ;
13
+ error . status = 400 ;
14
+
15
+ const wrappedError = wrapInOpenaiError ( error as LangchainError ) ;
16
+
17
+ expect ( wrappedError ) . toBeInstanceOf ( NonRetryableOpenaiAPIError ) ;
18
+ expect ( wrappedError . message ) . toBe ( `OpenaiAPIError: ${ DESCRIPTION_LENGTH_ERROR_LOG_MESSAGE } ` ) ;
19
+ } ) ;
20
+ } ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments