Remove gemini and ollama

This commit is contained in:
LeoMortari
2025-10-03 18:46:22 -03:00
parent 558a625f11
commit 43be1244c7
10 changed files with 5 additions and 193 deletions

View File

@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GeminiController } from './gemini.controller';
describe('GeminiController', () => {
let controller: GeminiController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [GeminiController],
}).compile();
controller = module.get<GeminiController>(GeminiController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -1,4 +0,0 @@
import { Module } from '@nestjs/common';
@Module({})
export class GeminiModule {}

View File

@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GeminiService } from './gemini.service';
describe('GeminiService', () => {
let service: GeminiService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [GeminiService],
}).compile();
service = module.get<GeminiService>(GeminiService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -1,45 +0,0 @@
import { Injectable } from '@nestjs/common';
import OpenAI from 'openai';
@Injectable()
export class GeminiService {
private readonly model = 'gemini-2.0-flash';
private readonly systemPrompt =
'Você é um assistente de IA que responde em portugues.';
private readonly gemini = new OpenAI({
apiKey: process.env.GEMINI_API_KEY,
baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai/',
});
public async generate({
model = this.model,
message,
systemPrompt = this.systemPrompt,
}: {
model?: string;
message: string;
systemPrompt?: string;
}) {
try {
const response = await this.gemini.chat.completions.create({
model,
messages: [
{
role: 'system',
content: systemPrompt,
},
{
role: 'user',
content: message,
},
],
});
return response;
} catch (error) {
throw new Error(error as string);
}
}
}

View File

@@ -1,10 +0,0 @@
import { IsNotEmpty, IsString } from 'class-validator';
export class ChatDto {
@IsString()
@IsNotEmpty()
message: string;
@IsString()
model: string;
}

View File

@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OllamaController } from './ollama.controller';
describe('OllamaController', () => {
let controller: OllamaController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [OllamaController],
}).compile();
controller = module.get<OllamaController>(OllamaController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -1,7 +0,0 @@
import { Module } from '@nestjs/common';
import { OllamaService } from './ollama.service';
@Module({
providers: [OllamaService],
})
export class OllamaModule {}

View File

@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OllamaService } from './ollama.service';
describe('OllamaService', () => {
let service: OllamaService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [OllamaService],
}).compile();
service = module.get<OllamaService>(OllamaService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -1,55 +0,0 @@
import { Ollama } from 'ollama';
import { Injectable } from '@nestjs/common';
import type { ListResponse, ModelResponse } from 'ollama';
@Injectable()
export class OllamaService {
private readonly ollama: Ollama;
constructor() {
this.ollama = new Ollama({ host: 'http://154.12.229.181:11434' });
}
public async getModels({ onlyChats }: { onlyChats: boolean }) {
try {
const modelsData = await this.ollama.list();
if (onlyChats) {
return this.getChatModels(modelsData);
}
return modelsData.models;
} catch (error) {
throw new Error(error as string);
}
}
public getChatModels(modelsData: ListResponse): ModelResponse[] {
const excludeFamilies = ['nomic-bert', 'embed', 'embedding'];
return modelsData.models.filter((model) => {
const families = model.details?.families || [];
return !families.some((f) => excludeFamilies.includes(f.toLowerCase()));
});
}
public async generateChat({
model,
message,
}: {
model: string;
message: string;
}) {
try {
const response = await this.ollama.chat({
model,
messages: [{ role: 'user', content: message }],
});
return response.message.content;
} catch (error) {
throw new Error(error as string);
}
}
}

View File

@@ -60,6 +60,11 @@ export class CreateVideoDto {
@MaxLength(244)
description?: string;
@IsOptional()
@IsUrl()
@MaxLength(244)
transcriptionUrl?: string;
@IsOptional()
@IsNumber(
{ allowNaN: false, allowInfinity: false },