@@ -531,20 +531,23 @@ export async function generateText({
531
531
const openai = createOpenAI ( {
532
532
apiKey,
533
533
baseURL : endpoint ,
534
- fetch : async ( url : string , options : any ) => {
534
+ fetch : async ( input : RequestInfo | URL , init ?: RequestInit ) : Promise < Response > => {
535
+ const url = typeof input === 'string' ? input : input . toString ( ) ;
535
536
const chain_id =
536
537
runtime . getSetting ( "ETERNALAI_CHAIN_ID" ) || "45762" ;
538
+
539
+ const options : RequestInit = { ...init } ;
537
540
if ( options ?. body ) {
538
- const body = JSON . parse ( options . body ) ;
541
+ const body = JSON . parse ( options . body as string ) ;
539
542
body . chain_id = chain_id ;
540
543
options . body = JSON . stringify ( body ) ;
541
544
}
545
+
542
546
const fetching = await runtime . fetch ( url , options ) ;
543
- if (
544
- parseBooleanFromText (
545
- runtime . getSetting ( "ETERNALAI_LOG" )
546
- )
547
- ) {
547
+
548
+ if ( parseBooleanFromText (
549
+ runtime . getSetting ( "ETERNALAI_LOG" )
550
+ ) ) {
548
551
elizaLogger . info (
549
552
"Request data: " ,
550
553
JSON . stringify ( options , null , 2 )
@@ -1195,7 +1198,6 @@ export async function splitChunks(
1195
1198
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
1196
1199
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
1197
1200
* @param opts.serverUrl The URL of the API server
1198
- * @param opts.token The API token for authentication
1199
1201
* @param opts.max_context_length Maximum allowed context length in tokens
1200
1202
* @param opts.max_response_length Maximum allowed response length in tokens
1201
1203
* @returns Promise resolving to a boolean value parsed from the model's response
0 commit comments