ai-protocol-adapters 1.0.0-alpha.16 → 1.0.0-alpha.17

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
@@ -695,9 +695,23 @@ var MessageConverter = class {
695
695
  }
696
696
  /**
697
697
  * 转换图片内容格式
698
+ * 支持两种格式:URL 和 base64
698
699
  */
699
700
  static convertImageContent(item) {
700
- if (item.source && item.source.type === "base64" && item.source.data && item.source.media_type) {
701
+ if (!item.source) {
702
+ return null;
703
+ }
704
+ if (item.source.type === "url" && item.source.url) {
705
+ return {
706
+ type: "image_url",
707
+ image_url: {
708
+ url: item.source.url,
709
+ detail: "auto"
710
+ // OpenAI 支持的可选参数
711
+ }
712
+ };
713
+ }
714
+ if (item.source.type === "base64" && item.source.data && item.source.media_type) {
701
715
  if (!SUPPORTED_IMAGE_TYPES.includes(item.source.media_type)) {
702
716
  console.warn(`\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F: ${item.source.media_type}`);
703
717
  return null;
@@ -706,7 +720,8 @@ var MessageConverter = class {
706
720
  return {
707
721
  type: "image_url",
708
722
  image_url: {
709
- url: dataUri
723
+ url: dataUri,
724
+ detail: "auto"
710
725
  }
711
726
  };
712
727
  }
package/dist/index.mjs CHANGED
@@ -588,9 +588,23 @@ var MessageConverter = class {
588
588
  }
589
589
  /**
590
590
  * 转换图片内容格式
591
+ * 支持两种格式:URL 和 base64
591
592
  */
592
593
  static convertImageContent(item) {
593
- if (item.source && item.source.type === "base64" && item.source.data && item.source.media_type) {
594
+ if (!item.source) {
595
+ return null;
596
+ }
597
+ if (item.source.type === "url" && item.source.url) {
598
+ return {
599
+ type: "image_url",
600
+ image_url: {
601
+ url: item.source.url,
602
+ detail: "auto"
603
+ // OpenAI 支持的可选参数
604
+ }
605
+ };
606
+ }
607
+ if (item.source.type === "base64" && item.source.data && item.source.media_type) {
594
608
  if (!SUPPORTED_IMAGE_TYPES.includes(item.source.media_type)) {
595
609
  console.warn(`\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F: ${item.source.media_type}`);
596
610
  return null;
@@ -599,7 +613,8 @@ var MessageConverter = class {
599
613
  return {
600
614
  type: "image_url",
601
615
  image_url: {
602
- url: dataUri
616
+ url: dataUri,
617
+ detail: "auto"
603
618
  }
604
619
  };
605
620
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-protocol-adapters",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.17",
4
4
  "description": "Universal AI Protocol Converter - OpenAI ⇄ Anthropic with full TypeScript support",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",