@3-/aiapi 0.1.38 → 0.1.40
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/gemini.js +7 -3
- package/package.json +1 -1
package/gemini.js
CHANGED
|
@@ -21,7 +21,7 @@ export default (token_li) => {
|
|
|
21
21
|
return _NEXT_TOKEN.next().value;
|
|
22
22
|
};
|
|
23
23
|
return async(text, schema, system, option) => {
|
|
24
|
-
var body, err, error, message, r, retryed, status;
|
|
24
|
+
var body, err, error, message, parts, r, retryed, status;
|
|
25
25
|
body = {
|
|
26
26
|
contents: [
|
|
27
27
|
{
|
|
@@ -95,8 +95,12 @@ export default (token_li) => {
|
|
|
95
95
|
r = ((await r.json())).candidates[0];
|
|
96
96
|
if (schema) {
|
|
97
97
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
({parts} = r.content);
|
|
99
|
+
if (!parts) {
|
|
100
|
+
console.warn('miss parts', r.content);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
r = JSON.parse(parts[0].text);
|
|
100
104
|
} catch (error1) {
|
|
101
105
|
err = error1;
|
|
102
106
|
console.error(body, r, err);
|