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