Hotfix tests after AI PR (#6124)

I merged https://github.com/twentyhq/twenty/pull/5788 too quickly and
didn't noticed it was broken with
https://github.com/twentyhq/twenty/pull/6069
This commit is contained in:
Félix Malfait
2024-07-04 10:21:33 +02:00
committed by GitHub
parent 4c642a0bb8
commit 5b4d2d989a
5 changed files with 8 additions and 13 deletions

View File

@ -8,8 +8,6 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import groupBy from 'lodash.groupby';
import { PartialFieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/partial-field-metadata.interface';
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { WorkspaceQueryRunnerService } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service';
import { LLMChatModelService } from 'src/engine/integrations/llm-chat-model/llm-chat-model.service';
@ -17,7 +15,6 @@ import { LLMTracingService } from 'src/engine/integrations/llm-tracing/llm-traci
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { DEFAULT_LABEL_IDENTIFIER_FIELD_NAME } from 'src/engine/metadata-modules/object-metadata/object-metadata.constants';
import { StandardObjectFactory } from 'src/engine/workspace-manager/workspace-sync-metadata/factories/standard-object.factory';
import { standardObjectMetadataDefinitions } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects';
import { AISQLQueryResult } from 'src/engine/core-modules/ai-sql-query/dtos/ai-sql-query-result.dto';
import { sqlGenerationPromptTemplate } from 'src/engine/core-modules/ai-sql-query/ai-sql-query.prompt-templates';
@ -43,7 +40,7 @@ export class AISQLQueryService {
fieldMetadata.id === objectMetadata.labelIdentifierFieldMetadataId,
);
const standardObjectMetadataCollection = this.standardObjectFactory.create(
/* const standardObjectMetadataCollection = this.standardObjectFactory.create(
standardObjectMetadataDefinitions,
{ workspaceId, dataSourceId },
workspaceFeatureFlagsMap,
@ -58,11 +55,11 @@ export class AISQLQueryService {
?.fields.find(
(field: PartialFieldMetadata) =>
field.name === DEFAULT_LABEL_IDENTIFIER_FIELD_NAME,
) as PartialFieldMetadata;
) as PartialFieldMetadata; */
const labelIdentifierFieldMetadata =
customObjectLabelIdentifierFieldMetadata ??
standardObjectLabelIdentifierFieldMetadata;
customObjectLabelIdentifierFieldMetadata; /*??
standardObjectLabelIdentifierFieldMetadata*/
return (
labelIdentifierFieldMetadata?.name ?? DEFAULT_LABEL_IDENTIFIER_FIELD_NAME

View File

@ -371,7 +371,7 @@ export class EnvironmentVariables {
OPENROUTER_API_KEY: string;
LLM_CHAT_MODEL_DRIVER: LLMChatModelDriver = LLMChatModelDriver.OpenAI;
LLM_CHAT_MODEL_DRIVER: LLMChatModelDriver;
OPENAI_API_KEY: string;

View File

@ -9,6 +9,6 @@ export interface LLMChatModelModuleOptions {
}
export type LLMChatModelModuleAsyncOptions = {
useFactory: (...args: any[]) => LLMChatModelModuleOptions;
useFactory: (...args: any[]) => LLMChatModelModuleOptions | undefined;
} & Pick<ModuleMetadata, 'imports'> &
Pick<FactoryProvider, 'inject'>;

View File

@ -12,8 +12,6 @@ export const llmChatModelModuleFactory = (
return { type: LLMChatModelDriver.OpenAI };
}
default:
throw new Error(
`Invalid LLM chat model driver (${driver}), check your .env file`,
);
// `No LLM chat model driver (${driver})`);
}
};

View File

@ -17,7 +17,7 @@ export class LLMChatModelModule {
useFactory: (...args: any[]) => {
const config = options.useFactory(...args);
switch (config.type) {
switch (config?.type) {
case LLMChatModelDriver.OpenAI: {
return new OpenAIDriver();
}