57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { Body, Controller, Post } from '@nestjs/common';
|
|
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
|
|
import { ExternalDataService } from './external-data.service';
|
|
|
|
class LegislationSearchDto {
|
|
@IsString() scenario: string;
|
|
@IsOptional() @IsString() country?: string;
|
|
@IsOptional() @IsNumber() topK?: number;
|
|
}
|
|
|
|
class LegislationAskDto {
|
|
@IsString() message: string;
|
|
@IsOptional() @IsString() country?: string;
|
|
@IsOptional() @IsEnum(['general', 'fiscal', 'national']) type?: 'general' | 'fiscal' | 'national';
|
|
@IsOptional() @IsString() sessionId?: string;
|
|
}
|
|
|
|
class CapabilityCheckDto {
|
|
@IsString() capability: string;
|
|
@IsOptional() @IsString() context?: string;
|
|
}
|
|
|
|
@Controller('external')
|
|
export class ExternalDataController {
|
|
constructor(private readonly svc: ExternalDataService) {}
|
|
|
|
/**
|
|
* POST /v1/external/legislation/search
|
|
* Vector search direct în corpusul legislativ — returnează secțiuni text.
|
|
* 'scenario': descrie situația completă (ex: "Am o firmă GmbH și vreau să angajez remote")
|
|
*/
|
|
@Post('legislation/search')
|
|
searchLegislation(@Body() dto: LegislationSearchDto) {
|
|
return this.svc.searchLegislation(dto.scenario, dto.country, dto.topK);
|
|
}
|
|
|
|
/**
|
|
* POST /v1/external/legislation/ask
|
|
* Răspuns AI via agent AnythingLLM, rutare automată după country + type.
|
|
* country: RO | DE | FR | UK | EU
|
|
* type: general | fiscal | national
|
|
*/
|
|
@Post('legislation/ask')
|
|
askLegislation(@Body() dto: LegislationAskDto) {
|
|
return this.svc.askLegislationAgent(
|
|
dto.message,
|
|
dto.country ?? 'RO',
|
|
dto.type ?? 'general',
|
|
dto.sessionId,
|
|
);
|
|
}
|
|
|
|
@Post('capability/check')
|
|
checkCapability(@Body() dto: CapabilityCheckDto) {
|
|
return this.svc.checkCapability(dto.capability, dto.context);
|
|
}
|
|
}
|