35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { Body, Controller, Get, Headers, Inject, Post, Query } from '@nestjs/common';
|
|
import { ok } from '../common/api-response.js';
|
|
import { actorFromHeaders } from '../common/auth-context.js';
|
|
import { ChatAskInput, ChatService } from './chat.service.js';
|
|
|
|
@Controller('api/v1/chat')
|
|
export class ChatController {
|
|
constructor(@Inject(ChatService) private readonly svc: ChatService) {}
|
|
|
|
@Post('ask')
|
|
ask(@Headers() headers: Record<string, string | string[] | undefined>, @Body() body: ChatAskInput) {
|
|
return ok(this.svc.ask(body, actorFromHeaders(headers)));
|
|
}
|
|
|
|
@Get('audit/verify')
|
|
verifyAudit() {
|
|
return ok(this.svc.verifyAudit());
|
|
}
|
|
|
|
@Get('replay')
|
|
replay(@Query('chatId') chatId?: string, @Query('turnId') turnId?: string, @Query('tenant') tenant?: string) {
|
|
return ok(this.svc.replay(chatId || '', turnId || '', tenant || ''));
|
|
}
|
|
|
|
@Get('actions')
|
|
actions(@Headers() headers: Record<string, string | string[] | undefined>) {
|
|
return ok(this.svc.listActions(actorFromHeaders(headers)));
|
|
}
|
|
|
|
@Get('agents')
|
|
agents(@Headers() headers: Record<string, string | string[] | undefined>) {
|
|
return ok(this.svc.listAgents(actorFromHeaders(headers)));
|
|
}
|
|
}
|