@3-/aiapi 0.1.32 → 0.1.34
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/factCheck.js +2 -1
- package/gemini.js +7 -4
- package/package.json +2 -2
package/factCheck.js
CHANGED
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, status;
|
|
24
|
+
var body, err, error, message, r, retryed, status;
|
|
25
25
|
body = {
|
|
26
26
|
contents: [
|
|
27
27
|
{
|
|
@@ -49,6 +49,7 @@ export default (token_li) => {
|
|
|
49
49
|
}
|
|
50
50
|
// console.log JSON.stringify body,null,2
|
|
51
51
|
body = JSON.stringify(body);
|
|
52
|
+
retryed = token_li.length;
|
|
52
53
|
while (true) {
|
|
53
54
|
try {
|
|
54
55
|
r = (await fetch('https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent', {
|
|
@@ -93,13 +94,15 @@ export default (token_li) => {
|
|
|
93
94
|
}
|
|
94
95
|
r = ((await r.json())).candidates[0];
|
|
95
96
|
if (schema) {
|
|
96
|
-
r = r.content.parts[0].text;
|
|
97
97
|
try {
|
|
98
|
+
r = r.content.parts[0].text;
|
|
98
99
|
r = JSON.parse(r);
|
|
99
100
|
} catch (error1) {
|
|
100
101
|
err = error1;
|
|
101
|
-
console.error(r);
|
|
102
|
-
|
|
102
|
+
console.error(r, err);
|
|
103
|
+
if (--retryed <= 0) {
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
108
|
return r;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3-/aiapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://atomgit.com/i18n/lib.git"
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://atomgit.com/i18n/lib/tree/dev/aiapi",
|
|
9
9
|
"author": "i18n.site@gmail.com",
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "MulanPSL-2.0",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./lib.js",
|
|
13
13
|
"./*": "./*"
|