@runnerpro/backend 1.13.6 → 1.13.8
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
|
@@ -20,12 +20,28 @@ const getVertexChat = () => {
|
|
|
20
20
|
};
|
|
21
21
|
exports.getVertexChat = getVertexChat;
|
|
22
22
|
const sendPrompt = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
var _a
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
try {
|
|
25
|
+
const chat = getVertexChat();
|
|
26
|
+
const result = yield chat.sendMessage(message);
|
|
27
|
+
// Verificar que la respuesta tiene la estructura esperada
|
|
28
|
+
if (!result.response.candidates || result.response.candidates.length === 0) {
|
|
29
|
+
throw new Error('No se recibieron candidatos en la respuesta');
|
|
30
|
+
}
|
|
31
|
+
const candidate = result.response.candidates[0];
|
|
32
|
+
if (!candidate.content || !candidate.content.parts || candidate.content.parts.length === 0) {
|
|
33
|
+
throw new Error('La respuesta no tiene contenido válido');
|
|
34
|
+
}
|
|
35
|
+
return ((_a = candidate.content.parts[0]) === null || _a === void 0 ? void 0 : _a.text) || '';
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error('Error en sendPrompt:', error);
|
|
39
|
+
console.error('Detalles del error:', {
|
|
40
|
+
message: error.message,
|
|
41
|
+
stack: error.stack,
|
|
42
|
+
name: error.name,
|
|
43
|
+
});
|
|
44
|
+
throw error; // Re-lanzar el error para que puedas manejarlo donde llames a sendPrompt
|
|
45
|
+
}
|
|
30
46
|
});
|
|
31
47
|
exports.sendPrompt = sendPrompt;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
declare const getVertexChat: () => import("@google-cloud/vertexai").ChatSessionPreview;
|
|
2
|
-
declare const sendPrompt: (message:
|
|
2
|
+
declare const sendPrompt: (message: string) => Promise<string>;
|
|
3
3
|
export { getVertexChat, sendPrompt };
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,aAAa,2DAQlB,CAAC;AAEF,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,aAAa,2DAQlB,CAAC;AAEF,QAAA,MAAM,UAAU,YAAmB,MAAM,KAAG,QAAQ,MAAM,CAyBzD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|