(url: string, body: any, headers: Record<string, string>, timeout = 120000)
| 331 | } |
| 332 | |
| 333 | async function glmPostStream(url: string, body: any, headers: Record<string, string>, timeout = 120000): Promise<Response> { |
| 334 | const controller = new AbortController(); |
| 335 | const timeoutId = setTimeout(() => controller.abort(), timeout); |
| 336 | try { |
| 337 | return await fetch(url, { |
| 338 | method: "POST", |
| 339 | headers, |
| 340 | body: JSON.stringify(body), |
| 341 | signal: controller.signal, |
| 342 | }); |
| 343 | } finally { |
| 344 | clearTimeout(timeoutId); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | export async function createCompletion(messages: any[], refreshToken: string, model = MODEL_NAME, refConvId = "", retryCount = 0, tools?: any[]): Promise<any> { |
| 349 | return (async () => { |
no test coverage detected