fix error

This commit is contained in:
Дания
2025-06-12 21:07:06 +03:00
parent 548dbfcc9d
commit 39a62818e9
4 changed files with 108 additions and 11 deletions

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePicture = exports.llm = void 0;
const gigachat_1 = require("gigachat");
const node_https_1 = require("node:https");
const httpsAgent = new node_https_1.Agent({
rejectUnauthorized: false,
});
exports.llm = new gigachat_1.GigaChat({
credentials: process.env.GIGA_AUTH,
model: 'GigaChat-2',
httpsAgent,
});
const generatePicture = async (prompt) => {
const resp = await exports.llm.chat({
messages: [
{
"role": "system",
"content": "Ты — Василий Кандинский для жильцов многоквартирного дома"
},
{
role: "user",
content: `Старайся передать атмосферу уюта и безопасности.
Нарисуй картинку подходящую для такого события: ${prompt}
В картинке не должно быть текста, только изображение.`,
},
],
function_call: 'auto',
});
// Получение изображения по идентификатору
const detectedImage = (0, gigachat_1.detectImage)(resp.choices[0]?.message.content ?? '');
const image = await exports.llm.getImage(detectedImage?.uuid ?? '');
// Возвращаем содержимое изображения
return image.content;
};
exports.generatePicture = generatePicture;