MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / callOpenAI

Function callOpenAI

sum/sum.ts:306–343  ·  view source on GitHub ↗
(
  apiKey: string,
  baseUrl: string,
  model: string,
  messages: string,
  prompt: string,
  timeout: number = 60000
)

Source from the content-addressed store, hash-verified

304 if (
305 importResult &&
306 typeof importResult === "object" &&
307 "chats" in importResult
308 ) {
309 const chats = (importResult as Record<string, unknown>).chats;
310 if (Array.isArray(chats) && chats.length > 0) {
311 entity = chats[0] as typeof entity;
312 id = entity?.id;
313 }
314 }
315 }
316 } catch (inviteError: any) {
317 console.error("处理邀请链接失败:", inviteError);
318 throw new Error(
319 `无法处理邀请链接: ${inviteError.message || "未知错误"}`,
320 );
321 }
322 } else {
323 // 普通的 username 或 ID,直接获取 entity
324 entity = await client.getEntity(target);
325 id = entity?.id;
326 }
327 } catch (e: any) {
328 console.error(e);
329 throw new Error(`无法获取群组信息: ${e.message || "未知错误"}`);
330 }
331
332 const displayParts: string[] = [];
333 if (entity?.title) displayParts.push(htmlEscape(entity.title));
334 if (entity?.username) displayParts.push(htmlEscape(`@${entity.username}`));
335 if (id) displayParts.push(codeTag(id));
336
337 return {
338 id,
339 entity,
340 display: displayParts.join(" ").trim(),
341 };
342}
343
344// AI 调用函数
345function normalizedBaseUrl(baseUrl: string): string {
346 // 允许用户填写根地址、末尾 / 或常见的 /v1;具体端点由插件统一追加。

Callers 1

summarizeMessagesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected