feat: fix ai agent
Some checks failed
Build Containers / build-containers-common (push) Has been cancelled
Build / build (22.12.0) (push) Has been cancelled
Build Containers / build-containers (amd64, ubuntu-latest) (push) Has been cancelled
Build Containers / build-containers (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Build Containers / build-container-manifest (push) Has been cancelled
Some checks failed
Build Containers / build-containers-common (push) Has been cancelled
Build / build (22.12.0) (push) Has been cancelled
Build Containers / build-containers (amd64, ubuntu-latest) (push) Has been cancelled
Build Containers / build-containers (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Build Containers / build-container-manifest (push) Has been cancelled
This commit is contained in:
parent
029ddb29d1
commit
945dc09f48
6 changed files with 41 additions and 9 deletions
|
|
@ -85,7 +85,7 @@ export class LoadToolsService {
|
|||
)}
|
||||
`;
|
||||
},
|
||||
model: openai('gpt-4.1'),
|
||||
model: openai('gpt-5.2'),
|
||||
tools,
|
||||
memory: new Memory({
|
||||
storage: pStore,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { AgentToolInterface, ToolReturn } from '@gitroom/nestjs-libraries/chat/agent.tool.interface';
|
||||
import {
|
||||
AgentToolInterface,
|
||||
ToolReturn,
|
||||
} from '@gitroom/nestjs-libraries/chat/agent.tool.interface';
|
||||
import { createTool } from '@mastra/core/tools';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
|
||||
import { getValidationSchemas } from '@gitroom/nestjs-libraries/chat/validation.schemas.helper';
|
||||
import { VideoManager } from '@gitroom/nestjs-libraries/videos/video.manager';
|
||||
import z from 'zod';
|
||||
import { checkAuth } from '@gitroom/nestjs-libraries/chat/auth.context';
|
||||
|
|
@ -42,7 +45,7 @@ export class GenerateVideoOptionsTool implements AgentToolInterface {
|
|||
type: p.identifier,
|
||||
output: 'vertical|horizontal',
|
||||
tools: p.tools,
|
||||
customParams: validationMetadatasToSchemas()[p.dto.name],
|
||||
customParams: getValidationSchemas()[p.dto.name],
|
||||
};
|
||||
}),
|
||||
},
|
||||
|
|
@ -50,13 +53,14 @@ export class GenerateVideoOptionsTool implements AgentToolInterface {
|
|||
2
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
video: videos.map((p) => {
|
||||
return {
|
||||
type: p.identifier,
|
||||
output: 'vertical|horizontal',
|
||||
tools: p.tools,
|
||||
customParams: validationMetadatasToSchemas()[p.dto.name],
|
||||
customParams: getValidationSchemas()[p.dto.name],
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
IntegrationManager,
|
||||
socialIntegrationList,
|
||||
} from '@gitroom/nestjs-libraries/integrations/integration.manager';
|
||||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
|
||||
import { IntegrationService } from '@gitroom/nestjs-libraries/database/prisma/integrations/integration.service';
|
||||
import { RefreshToken } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { timer } from '@gitroom/helpers/utils/timer';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
IntegrationManager,
|
||||
socialIntegrationList,
|
||||
} from '@gitroom/nestjs-libraries/integrations/integration.manager';
|
||||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
|
||||
import { IntegrationService } from '@gitroom/nestjs-libraries/database/prisma/integrations/integration.service';
|
||||
import { RefreshToken } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { timer } from '@gitroom/helpers/utils/timer';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
IntegrationManager,
|
||||
socialIntegrationList,
|
||||
} from '@gitroom/nestjs-libraries/integrations/integration.manager';
|
||||
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
|
||||
import { getValidationSchemas } from '@gitroom/nestjs-libraries/chat/validation.schemas.helper';
|
||||
import { checkAuth } from '@gitroom/nestjs-libraries/chat/auth.context';
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -88,7 +88,7 @@ export class IntegrationValidationTool implements AgentToolInterface {
|
|||
const maxLength = integration.maxLength(context.isPremium);
|
||||
const schemas = !integration.dto
|
||||
? false
|
||||
: validationMetadatasToSchemas()[integration.dto.name];
|
||||
: getValidationSchemas()[integration.dto.name];
|
||||
const tools = this._integrationManager.getAllTools();
|
||||
const rules = this._integrationManager.getAllRulesDescription();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import {
|
||||
validationMetadatasToSchemas,
|
||||
targetConstructorToSchema,
|
||||
} from 'class-validator-jsonschema';
|
||||
import { ValidationTypes } from 'class-validator';
|
||||
// @ts-ignore
|
||||
import { defaultMetadataStorage } from 'class-transformer/cjs/storage';
|
||||
|
||||
export function getValidationSchemas() {
|
||||
return validationMetadatasToSchemas({
|
||||
classTransformerMetadataStorage: defaultMetadataStorage,
|
||||
additionalConverters: {
|
||||
[ValidationTypes.NESTED_VALIDATION]: (meta, options) => {
|
||||
if (typeof meta.target === 'function') {
|
||||
const typeMeta = options.classTransformerMetadataStorage
|
||||
? options.classTransformerMetadataStorage.findTypeMetadata(
|
||||
meta.target,
|
||||
meta.propertyName
|
||||
)
|
||||
: null;
|
||||
if (typeMeta) {
|
||||
const childType = typeMeta.typeFunction();
|
||||
return targetConstructorToSchema(childType, options);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue