@@ -451,20 +451,23 @@ export async function generateText({
451
451
const openai = createOpenAI ( {
452
452
apiKey,
453
453
baseURL : endpoint ,
454
- fetch : async ( url : string , options : any ) => {
454
+ fetch : async ( input : RequestInfo | URL , init ?: RequestInit ) : Promise < Response > => {
455
+ const url = typeof input === 'string' ? input : input . toString ( ) ;
455
456
const chain_id =
456
457
runtime . getSetting ( "ETERNALAI_CHAIN_ID" ) || "45762" ;
458
+
459
+ const options : RequestInit = { ...init } ;
457
460
if ( options ?. body ) {
458
- const body = JSON . parse ( options . body ) ;
461
+ const body = JSON . parse ( options . body as string ) ;
459
462
body . chain_id = chain_id ;
460
463
options . body = JSON . stringify ( body ) ;
461
464
}
465
+
462
466
const fetching = await runtime . fetch ( url , options ) ;
463
- if (
464
- parseBooleanFromText (
465
- runtime . getSetting ( "ETERNALAI_LOG" )
466
- )
467
- ) {
467
+
468
+ if ( parseBooleanFromText (
469
+ runtime . getSetting ( "ETERNALAI_LOG" )
470
+ ) ) {
468
471
elizaLogger . info (
469
472
"Request data: " ,
470
473
JSON . stringify ( options , null , 2 )
@@ -1102,7 +1105,6 @@ export async function splitChunks(
1102
1105
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
1103
1106
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
1104
1107
* @param opts.serverUrl The URL of the API server
1105
- * @param opts.token The API token for authentication
1106
1108
* @param opts.max_context_length Maximum allowed context length in tokens
1107
1109
* @param opts.max_response_length Maximum allowed response length in tokens
1108
1110
* @returns Promise resolving to a boolean value parsed from the model's response
0 commit comments