Spaces:
Sleeping
Sleeping
Update aiEngine.js
Browse files- aiEngine.js +14 -7
aiEngine.js
CHANGED
|
@@ -38,11 +38,13 @@ export const AIEngine = {
|
|
| 38 |
config,
|
| 39 |
contents,
|
| 40 |
});
|
|
|
|
|
|
|
| 41 |
|
| 42 |
// Return both text and usage metadata
|
| 43 |
return {
|
| 44 |
text: response.text,
|
| 45 |
-
usage: response.usageMetadata
|
| 46 |
};
|
| 47 |
|
| 48 |
} catch (error) {
|
|
@@ -93,11 +95,13 @@ export const AIEngine = {
|
|
| 93 |
config,
|
| 94 |
contents,
|
| 95 |
});
|
| 96 |
-
|
|
|
|
|
|
|
| 97 |
// Return both text and usage metadata
|
| 98 |
return {
|
| 99 |
text: response.text,
|
| 100 |
-
usage: response.usageMetadata
|
| 101 |
};
|
| 102 |
|
| 103 |
} catch (error) {
|
|
@@ -127,11 +131,13 @@ export const AIEngine = {
|
|
| 127 |
|
| 128 |
const text = response.text;
|
| 129 |
const parsed = JSON.parse(text);
|
|
|
|
|
|
|
| 130 |
|
| 131 |
// Attach usage to the JSON object
|
| 132 |
return {
|
| 133 |
...parsed,
|
| 134 |
-
usage: response.usageMetadata
|
| 135 |
};
|
| 136 |
|
| 137 |
} catch (e) {
|
|
@@ -162,11 +168,12 @@ export const AIEngine = {
|
|
| 162 |
});
|
| 163 |
|
| 164 |
const parsed = JSON.parse(response.text);
|
|
|
|
| 165 |
|
| 166 |
// Attach usage to the JSON object
|
| 167 |
return {
|
| 168 |
...parsed,
|
| 169 |
-
usage: response.usageMetadata
|
| 170 |
};
|
| 171 |
|
| 172 |
} catch (e) {
|
|
@@ -226,10 +233,10 @@ export const AIEngine = {
|
|
| 226 |
|
| 227 |
// Retrieve the full response object to get usage metadata
|
| 228 |
const aggregatedResponse = await response.response;
|
| 229 |
-
|
| 230 |
return {
|
| 231 |
image: finalDataUrl,
|
| 232 |
-
usage: aggregatedResponse.usageMetadata
|
| 233 |
};
|
| 234 |
|
| 235 |
} catch (error) {
|
|
|
|
| 38 |
config,
|
| 39 |
contents,
|
| 40 |
});
|
| 41 |
+
|
| 42 |
+
console.log(response.usageMetadata.total_token_count);
|
| 43 |
|
| 44 |
// Return both text and usage metadata
|
| 45 |
return {
|
| 46 |
text: response.text,
|
| 47 |
+
usage: response.usageMetadata.total_token_count
|
| 48 |
};
|
| 49 |
|
| 50 |
} catch (error) {
|
|
|
|
| 95 |
config,
|
| 96 |
contents,
|
| 97 |
});
|
| 98 |
+
|
| 99 |
+
console.log(response.usageMetadata.total_token_count);
|
| 100 |
+
|
| 101 |
// Return both text and usage metadata
|
| 102 |
return {
|
| 103 |
text: response.text,
|
| 104 |
+
usage: response.usageMetadata.total_token_count
|
| 105 |
};
|
| 106 |
|
| 107 |
} catch (error) {
|
|
|
|
| 131 |
|
| 132 |
const text = response.text;
|
| 133 |
const parsed = JSON.parse(text);
|
| 134 |
+
|
| 135 |
+
console.log(response.usageMetadata.total_token_count)
|
| 136 |
|
| 137 |
// Attach usage to the JSON object
|
| 138 |
return {
|
| 139 |
...parsed,
|
| 140 |
+
usage: response.usageMetadata.total_token_count
|
| 141 |
};
|
| 142 |
|
| 143 |
} catch (e) {
|
|
|
|
| 168 |
});
|
| 169 |
|
| 170 |
const parsed = JSON.parse(response.text);
|
| 171 |
+
console.log(response.usageMetadata.total_token_count);
|
| 172 |
|
| 173 |
// Attach usage to the JSON object
|
| 174 |
return {
|
| 175 |
...parsed,
|
| 176 |
+
usage: response.usageMetadata.total_token_count
|
| 177 |
};
|
| 178 |
|
| 179 |
} catch (e) {
|
|
|
|
| 233 |
|
| 234 |
// Retrieve the full response object to get usage metadata
|
| 235 |
const aggregatedResponse = await response.response;
|
| 236 |
+
console.log(aggregatedResponse.usageMetadata.total_token_count);
|
| 237 |
return {
|
| 238 |
image: finalDataUrl,
|
| 239 |
+
usage: aggregatedResponse.usageMetadata.total_token_count
|
| 240 |
};
|
| 241 |
|
| 242 |
} catch (error) {
|