@kenkaiiii/gg-ai 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -151,7 +151,7 @@ function finaliseBySource(source, message, requestId, hint) {
151
151
  headline: message,
152
152
  source,
153
153
  message: "",
154
- guidance: hint ?? "Only Kimi, Gemini, and MiniMax can analyze video. Switch with /model.",
154
+ guidance: hint ?? "Only Kimi, Gemini, MiniMax, and MiMo-V2.5 can analyze video. Switch with /model.",
155
155
  ...requestId ? { requestId } : {}
156
156
  };
157
157
  case "ggcoder":
@@ -794,13 +794,14 @@ function toOpenAIMessages(messages, options) {
794
794
  }
795
795
  if (msg.role === "tool") {
796
796
  const isMoonshot = options?.provider === "moonshot";
797
- const imageBlocks = [];
797
+ const followUpMediaBlocks = [];
798
+ let followUpHasVideo = false;
798
799
  for (const result of msg.content) {
799
800
  const text = toolResultText(result.content);
800
801
  const images = toolResultImages(result.content);
801
- const videos = isMoonshot ? toolResultVideos(result.content) : [];
802
+ const videos = toolResultVideos(result.content);
802
803
  const hasText = text.length > 0;
803
- if (videos.length > 0) {
804
+ if (isMoonshot && videos.length > 0) {
804
805
  const parts = [];
805
806
  if (hasText) parts.push({ type: "text", text });
806
807
  const videoParts = videos.map((v) => {
@@ -817,21 +818,31 @@ function toOpenAIMessages(messages, options) {
817
818
  out.push({
818
819
  role: "tool",
819
820
  tool_call_id: remapToolCallId(result.toolCallId, idMap),
820
- content: hasText ? text : "(see attached image)"
821
+ content: hasText ? text : "(see attached media)"
821
822
  });
822
823
  if (images.length > 0 && options?.supportsImages !== false) {
823
824
  for (const img of images) {
824
- imageBlocks.push({
825
+ followUpMediaBlocks.push({
825
826
  type: "image_url",
826
827
  image_url: { url: `data:${img.mediaType};base64,${img.data}` }
827
828
  });
828
829
  }
829
830
  }
831
+ if (!isMoonshot && videos.length > 0) {
832
+ for (const v of videos) {
833
+ followUpMediaBlocks.push({
834
+ type: "video_url",
835
+ video_url: { url: `data:${v.mediaType};base64,${v.data}` }
836
+ });
837
+ followUpHasVideo = true;
838
+ }
839
+ }
830
840
  }
831
- if (imageBlocks.length > 0) {
841
+ if (followUpMediaBlocks.length > 0) {
842
+ const label = followUpHasVideo ? "Attached media from tool result:" : "Attached image(s) from tool result:";
832
843
  out.push({
833
844
  role: "user",
834
- content: [{ type: "text", text: "Attached image(s) from tool result:" }, ...imageBlocks]
845
+ content: [{ type: "text", text: label }, ...followUpMediaBlocks]
835
846
  });
836
847
  }
837
848
  }