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

Function getGroupMessages

sum/sum.ts:508–553  ·  view source on GitHub ↗
(chatId: string, count: number)

Source from the content-addressed store, hash-verified

506 return callAnthropic(
507 provider.api_key,
508 provider.base_url,
509 provider.model,
510 input,
511 timeout,
512 );
513 default:
514 return callChatCompletions(
515 provider.api_key,
516 provider.base_url,
517 provider.model,
518 input,
519 timeout,
520 );
521 }
522}
523
524function canTryFallback(error: unknown): boolean {
525 if (!axios.isAxiosError(error)) return false;
526 if (error.response?.status === 404) return true;
527 if (error.response?.status !== 400) return false;
528
529 const detail = JSON.stringify(error.response.data).toLowerCase();
530 return (
531 detail.includes("unsupported_upstream") ||
532 detail.includes("endpoint") ||
533 detail.includes("not supported")
534 );
535}
536
537async function callAI(
538 provider: CustomProvider,
539 messages: string,
540 prompt: string,
541 timeout: number,
542): Promise<string> {
543 const input = `${prompt}\n\n${messages}`;
544 const protocol = detectProtocol(provider);
545
546 try {
547 return await callWithProtocol(protocol, provider, input, timeout);
548 } catch (error) {
549 // 仅在网关明确不支持当前端点时,尝试 OpenAI 兼容接口。
550 if (
551 provider.type === "auto" &&
552 protocol !== "chat" &&
553 canTryFallback(error)
554 ) {
555 return callWithProtocol("chat", provider, input, timeout);
556 }

Callers 2

executeSummaryFunction · 0.85
SummaryPluginClass · 0.85

Calls 4

extractUrlsFromEntitiesFunction · 0.85
extractFileNameFunction · 0.85
formatDateFunction · 0.70
buildMessageLinkFunction · 0.70

Tested by

no test coverage detected