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

Method callGemini

xmsl/xmsl.ts:677–730  ·  view source on GitHub ↗
(question: string, imageInfo?: MediaInfo)

Source from the content-addressed store, hash-verified

675
676 // 构建内容部分
677 const parts: any[] = [];
678 if (question) {
679 parts.push({ text: question });
680 } else if (imageInfo) {
681 parts.push({ text: '请识别这张图片/贴纸的内容' });
682 }
683
684 if (imageInfo) {
685 parts.push({
686 inlineData: {
687 mimeType: imageInfo.mimeType,
688 data: imageInfo.base64,
689 },
690 });
691 }
692
693 const requestBody: any = {
694 contents: [{ parts }],
695 generationConfig: {
696 temperature: 0.7,
697 },
698 };
699
700 if (SYSTEM_PROMPT) {
701 requestBody.systemInstruction = {
702 parts: [{ text: SYSTEM_PROMPT }],
703 };
704 }
705
706 const response = await axios.post(
707 url,
708 requestBody,
709 {
710 params: { key: this.config.apiKey },
711 headers: { 'Content-Type': 'application/json' },
712 timeout: 60000,
713 }
714 );
715
716 const responseParts = response.data?.candidates?.[0]?.content?.parts || [];
717 return (
718 responseParts
719 .map((p: any) => p.text || '')
720 .join('')
721 .trim() || '无法获取回复'
722 );
723 }
724}
725
726export default new XMSLPlugin();

Callers 1

askAIMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected