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

Function handleGptRequest

outdated/gpt/gpt.ts:575–754  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

573
574// 主处理函数
575async function handleGptRequest(msg: Api.Message): Promise<void> {
576 const [, ...args] = msg.message.slice(1).split(" ");
577 let tempImagePath: string | undefined;
578
579 try {
580 // 检查是否是配置命令
581 if (args.length === 2 && args[0].startsWith("_set_")) {
582 const configKey = args[0];
583 const configValue = args[1].trim();
584
585 let actualKey: string;
586 let displayName: string;
587
588 switch (configKey) {
589 case "_set_key":
590 actualKey = CONFIG_KEYS.GPT_KEY;
591 displayName = "API Key";
592 break;
593 case "_set_api":
594 actualKey = CONFIG_KEYS.GPT_API;
595 displayName = "API URL";
596 break;
597 case "_set_model":
598 actualKey = CONFIG_KEYS.GPT_MODEL;
599 displayName = "模型";
600 break;
601 case "_set_vision_model":
602 actualKey = CONFIG_KEYS.GPT_VISION_MODEL;
603 displayName = "图像识别模型";
604 break;
605 case "_set_image_upload":
606 actualKey = CONFIG_KEYS.GPT_IMAGE_UPLOAD;
607 displayName = "图片上传";
608 break;
609 case "_set_web_search":
610 actualKey = CONFIG_KEYS.GPT_WEB_SEARCH;
611 displayName = "Web搜索";
612 break;
613 case "_set_auto_remove":
614 actualKey = CONFIG_KEYS.GPT_AUTO_REMOVE;
615 displayName = "自动删除";
616 break;
617 case "_set_max_tokens":
618 actualKey = CONFIG_KEYS.GPT_MAX_TOKENS;
619 displayName = "最大Token数";
620 break;
621 case "_set_collapse":
622 actualKey = CONFIG_KEYS.GPT_COLLAPSE;
623 displayName = "折叠引用";
624 break;
625 default:
626 await msg.edit({ text: "❌ 未知的配置项" });
627 return;
628 }
629
630 ConfigManager.set(actualKey, configValue);
631 const confirmMsg = await msg.edit({
632 text: `✅ 已设置 ${displayName}: \`${

Callers

nothing calls this directly

Calls 10

callGptApiFunction · 0.85
cleanupTempFileFunction · 0.85
errorMethod · 0.80
sleepFunction · 0.70
downloadAndProcessImageFunction · 0.70
formatResponseFunction · 0.70
editMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected