@runnerpro/backend 1.13.38 → 1.13.39
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/lib/cjs/prompt/index.js
CHANGED
|
@@ -10,12 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sendPrompt = void 0;
|
|
13
|
-
const
|
|
13
|
+
const vertexai_1 = require("@google-cloud/vertexai");
|
|
14
14
|
function sendPrompt(prompt) {
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
// Inicializa el cliente de Vertex AI
|
|
18
|
-
const vertex_ai = new VertexAI({
|
|
18
|
+
const vertex_ai = new vertexai_1.VertexAI({
|
|
19
19
|
project: process.env.PROJECT_ID, // Reemplaza con tu ID de proyecto de Google Cloud
|
|
20
20
|
location: 'europe-west8', // Reemplaza con tu región
|
|
21
21
|
});
|
|
@@ -30,22 +30,17 @@ function sendPrompt(prompt) {
|
|
|
30
30
|
topK: 20,
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) || '';
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
33
|
+
const resp = yield generativeModel.generateContent(prompt);
|
|
34
|
+
// Early return si no hay candidates
|
|
35
|
+
const candidate = (_a = resp.response.candidates) === null || _a === void 0 ? void 0 : _a[0];
|
|
36
|
+
if (!candidate)
|
|
37
|
+
return '';
|
|
38
|
+
// Early return si no hay parts
|
|
39
|
+
const parts = (_b = candidate.content) === null || _b === void 0 ? void 0 : _b.parts;
|
|
40
|
+
if (!parts || parts.length === 0)
|
|
41
|
+
return '';
|
|
42
|
+
// Return del texto si existe
|
|
43
|
+
return ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) || '';
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
46
|
exports.sendPrompt = sendPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AAkcF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,mBAgCvC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|