Skip to content

Commit 9cc6c51

Browse files
authored
Merge pull request #2220 from ai16z-demirix/fix/issue-2164
improvement: using strict types to avoid erorrs like issue 2164
2 parents 15b5d25 + 016cfff commit 9cc6c51

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/core/src/generation.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -531,20 +531,23 @@ export async function generateText({
531531
const openai = createOpenAI({
532532
apiKey,
533533
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();
535536
const chain_id =
536537
runtime.getSetting("ETERNALAI_CHAIN_ID") || "45762";
538+
539+
const options: RequestInit = { ...init };
537540
if (options?.body) {
538-
const body = JSON.parse(options.body);
541+
const body = JSON.parse(options.body as string);
539542
body.chain_id = chain_id;
540543
options.body = JSON.stringify(body);
541544
}
545+
542546
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+
)) {
548551
elizaLogger.info(
549552
"Request data: ",
550553
JSON.stringify(options, null, 2)
@@ -1195,7 +1198,6 @@ export async function splitChunks(
11951198
* @param opts.presence_penalty The presence penalty to apply (0.0 to 2.0)
11961199
* @param opts.temperature The temperature to control randomness (0.0 to 2.0)
11971200
* @param opts.serverUrl The URL of the API server
1198-
* @param opts.token The API token for authentication
11991201
* @param opts.max_context_length Maximum allowed context length in tokens
12001202
* @param opts.max_response_length Maximum allowed response length in tokens
12011203
* @returns Promise resolving to a boolean value parsed from the model's response

0 commit comments

Comments
 (0)