change moderate and initiatives

This commit is contained in:
Дания
2025-06-15 16:13:57 +03:00
parent ad35d47ff5
commit 37238a1385
5 changed files with 125 additions and 83 deletions

View File

@@ -1,19 +1,8 @@
import { GigaChat, detectImage } from 'gigachat';
import { Agent } from 'node:https';
import { llm_gen } from './llm'
import { detectImage } from 'gigachat';
const httpsAgent = new Agent({
rejectUnauthorized: false,
timeout: 60000
});
export const llm = new GigaChat({
credentials: process.env.GIGA_AUTH,
model: 'GigaChat-2',
httpsAgent,
});
export const generatePicture = async (prompt: string) => {
const resp = await llm.chat({
export const generatePicture = async (prompt: string, GIGA_AUTH) => {
const resp = await llm_gen(GIGA_AUTH).chat({
messages: [
{
"role": "system",
@@ -36,7 +25,7 @@ export const generatePicture = async (prompt: string) => {
throw new Error('Не удалось получить UUID изображения из ответа GigaChat');
}
const image = await llm.getImage(detectedImage.uuid);
const image = await llm_gen(GIGA_AUTH).getImage(detectedImage.uuid);
// Возвращаем содержимое изображения, убеждаясь что это Buffer
if (Buffer.isBuffer(image.content)) {