@gammatech/aijsx 0.16.4-dev.2024-11-24 → 0.16.5-dev.2024-11-25
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 +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -109,7 +109,12 @@ var ImagePart = (_props) => {
|
|
|
109
109
|
return null;
|
|
110
110
|
};
|
|
111
111
|
async function fetchImageAndConvertToBase64(url) {
|
|
112
|
-
|
|
112
|
+
let response;
|
|
113
|
+
try {
|
|
114
|
+
response = await fetch(url);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new Error(`Failed to fetch image URL ${url}: ${error.message}`);
|
|
117
|
+
}
|
|
113
118
|
const contentType = response.headers.get("content-type");
|
|
114
119
|
if (!contentType || !RE_ALLOWED_MEDIA_TYPES.test(contentType)) {
|
|
115
120
|
throw new Error(`Unsupported media type: ${contentType}`);
|
|
@@ -2691,7 +2696,6 @@ async function* AnthropicChatCompletionInner(props, ctx) {
|
|
|
2691
2696
|
const cacheCreated = inputUsage.cache_creation_input_tokens || 0;
|
|
2692
2697
|
const cacheRead = inputUsage.cache_read_input_tokens || 0;
|
|
2693
2698
|
const promptTokens = inputUsage.input_tokens + cacheCreated + cacheRead;
|
|
2694
|
-
logger.info(`inputUsage: ${JSON.stringify(inputUsage, null, 2)}`);
|
|
2695
2699
|
tokensUsed.prompt = promptTokens;
|
|
2696
2700
|
tokensUsed.cachedPromptTokensCreated = cacheCreated;
|
|
2697
2701
|
tokensUsed.cachedPromptTokensRead = cacheRead;
|
package/dist/index.mjs
CHANGED
|
@@ -41,7 +41,12 @@ var ImagePart = (_props) => {
|
|
|
41
41
|
return null;
|
|
42
42
|
};
|
|
43
43
|
async function fetchImageAndConvertToBase64(url) {
|
|
44
|
-
|
|
44
|
+
let response;
|
|
45
|
+
try {
|
|
46
|
+
response = await fetch(url);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error(`Failed to fetch image URL ${url}: ${error.message}`);
|
|
49
|
+
}
|
|
45
50
|
const contentType = response.headers.get("content-type");
|
|
46
51
|
if (!contentType || !RE_ALLOWED_MEDIA_TYPES.test(contentType)) {
|
|
47
52
|
throw new Error(`Unsupported media type: ${contentType}`);
|
|
@@ -2590,7 +2595,6 @@ async function* AnthropicChatCompletionInner(props, ctx) {
|
|
|
2590
2595
|
const cacheCreated = inputUsage.cache_creation_input_tokens || 0;
|
|
2591
2596
|
const cacheRead = inputUsage.cache_read_input_tokens || 0;
|
|
2592
2597
|
const promptTokens = inputUsage.input_tokens + cacheCreated + cacheRead;
|
|
2593
|
-
logger.info(`inputUsage: ${JSON.stringify(inputUsage, null, 2)}`);
|
|
2594
2598
|
tokensUsed.prompt = promptTokens;
|
|
2595
2599
|
tokensUsed.cachedPromptTokensCreated = cacheCreated;
|
|
2596
2600
|
tokensUsed.cachedPromptTokensRead = cacheRead;
|