mirror of
https://github.com/hexastack/hexabot
synced 2025-04-09 23:44:34 +00:00
fix: feedback udaptes
This commit is contained in:
parent
b684c6832d
commit
c9f411e813
@ -146,7 +146,7 @@ export class AttachmentController extends BaseController<Attachment> {
|
||||
@Get('download/:id/:filename?')
|
||||
async download(
|
||||
@Param() params: AttachmentDownloadDto,
|
||||
): Promise<StreamableFile | undefined> {
|
||||
): Promise<StreamableFile> {
|
||||
const attachment = await this.attachmentService.findOne(params.id);
|
||||
|
||||
if (!attachment) {
|
||||
|
@ -256,9 +256,15 @@ export class AttachmentService extends BaseService<Attachment> {
|
||||
async download(
|
||||
attachment: Attachment,
|
||||
rootDir = config.parameters.uploadDir,
|
||||
) {
|
||||
): Promise<StreamableFile> {
|
||||
if (this.getStoragePlugin()) {
|
||||
return await this.getStoragePlugin()?.download(attachment);
|
||||
const streamableFile =
|
||||
await this.getStoragePlugin()?.download(attachment);
|
||||
if (!streamableFile) {
|
||||
throw new NotFoundException('No file was found');
|
||||
}
|
||||
|
||||
return streamableFile;
|
||||
} else {
|
||||
const path = resolve(join(rootDir, attachment.location));
|
||||
|
||||
|
@ -146,7 +146,7 @@ export default class LlmNluHelper
|
||||
{
|
||||
entity: 'language',
|
||||
value: language || defaultLanguage.code,
|
||||
confidence: 0.0,
|
||||
confidence: 100,
|
||||
},
|
||||
];
|
||||
for await (const { name, doc, prompt, values } of this
|
||||
|
@ -125,7 +125,7 @@ describe('NlpValueController', () => {
|
||||
(acc, curr) => {
|
||||
const ValueWithEntities = {
|
||||
...curr,
|
||||
entity: nlpEntities[parseInt(curr.entity!)].id,
|
||||
entity: curr.entity ? nlpEntities[parseInt(curr.entity!)].id : null,
|
||||
expressions: curr.expressions!,
|
||||
metadata: curr.metadata!,
|
||||
builtin: curr.builtin!,
|
||||
@ -133,7 +133,7 @@ describe('NlpValueController', () => {
|
||||
acc.push(ValueWithEntities);
|
||||
return acc;
|
||||
},
|
||||
[] as TFixtures<NlpValue>[],
|
||||
[] as TFixtures<NlpValueCreateDto>[],
|
||||
);
|
||||
expect(result).toEqualPayload(nlpValueFixturesWithEntities);
|
||||
});
|
||||
|
@ -33,8 +33,13 @@ export class ObjectIdPipe implements PipeTransform<string, Promise<string>> {
|
||||
async transform(value: string, { type, data }: ArgumentMetadata) {
|
||||
if (typeof value === 'string' && data === 'id' && type === 'param') {
|
||||
const errors = await this.getErrors(value);
|
||||
if (errors?.constraints)
|
||||
throw new BadRequestException(Object.values(errors.constraints)[0]);
|
||||
if (errors) {
|
||||
throw new BadRequestException(
|
||||
errors?.constraints
|
||||
? Object.values(errors.constraints)[0]
|
||||
: errors.toString(),
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
typeof value === 'object' &&
|
||||
Object.keys(value).length > 1 &&
|
||||
@ -45,10 +50,13 @@ export class ObjectIdPipe implements PipeTransform<string, Promise<string>> {
|
||||
if (param.startsWith('id')) {
|
||||
const errors = await this.getErrors(String(paramValue));
|
||||
|
||||
if (errors?.constraints)
|
||||
if (errors) {
|
||||
throw new BadRequestException(
|
||||
Object.values(errors.constraints)[0],
|
||||
errors?.constraints
|
||||
? Object.values(errors.constraints)[0]
|
||||
: errors.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user