Skip to content

Commit

Permalink
Merge branch 'master' into ask-assistant
Browse files Browse the repository at this point in the history
* master:
  feat(editor): Auto-add LLM chain for new LLM nodes on empty canvas (#10245)
  fix(core): Fix user telemetry bugs (#10293)
  refactor(core): Remove stray log from telemetry event relay (no-changelog) (#10295)
  refactor(core): Decouple user events from internal hooks (no-changelog) (#10292)
  feat(core): Support community packages in scaling-mode  (#10228)
  test(core): Move unit tests closer to testable components (no-changelog) (#10287)
  fix(core): Webhook and form baseUrl missing (#10290)
  refactor(core): Port cache config (no-changelog) (#10286)
  • Loading branch information
MiloradFilipovic committed Aug 5, 2024
2 parents 827606e + 06419d9 commit a572adf
Show file tree
Hide file tree
Showing 151 changed files with 893 additions and 612 deletions.
2 changes: 1 addition & 1 deletion cypress/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const INSTANCE_MEMBERS = [
export const MANUAL_TRIGGER_NODE_NAME = 'Manual Trigger';
export const MANUAL_TRIGGER_NODE_DISPLAY_NAME = 'When clicking ‘Test workflow’';
export const MANUAL_CHAT_TRIGGER_NODE_NAME = 'Chat Trigger';
export const MANUAL_CHAT_TRIGGER_NODE_DISPLAY_NAME = 'When chat message received';
export const CHAT_TRIGGER_NODE_DISPLAY_NAME = 'When chat message received';
export const SCHEDULE_TRIGGER_NODE_NAME = 'Schedule Trigger';
export const CODE_NODE_NAME = 'Code';
export const SET_NODE_NAME = 'Set';
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/233-AI-switch-to-logs-on-error.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME,
AI_MEMORY_POSTGRES_NODE_NAME,
AI_TOOL_CALCULATOR_NODE_NAME,
MANUAL_CHAT_TRIGGER_NODE_DISPLAY_NAME,
CHAT_TRIGGER_NODE_DISPLAY_NAME,
MANUAL_CHAT_TRIGGER_NODE_NAME,
MANUAL_TRIGGER_NODE_DISPLAY_NAME,
MANUAL_TRIGGER_NODE_NAME,
Expand Down Expand Up @@ -148,7 +148,7 @@ function setupTestWorkflow(chatTrigger: boolean = false) {
if (!chatTrigger) {
// Remove chat trigger
WorkflowPage.getters
.canvasNodeByName(MANUAL_CHAT_TRIGGER_NODE_DISPLAY_NAME)
.canvasNodeByName(CHAT_TRIGGER_NODE_DISPLAY_NAME)
.find('[data-test-id="delete-node-button"]')
.click({ force: true });

Expand Down
26 changes: 26 additions & 0 deletions cypress/e2e/30-langchain.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
disableNode,
getExecuteWorkflowButton,
navigateToNewWorkflowPage,
getNodes,
openNode,
getConnectionBySourceAndTarget,
} from '../composables/workflow';
import {
clickCreateNewCredential,
Expand Down Expand Up @@ -41,6 +43,7 @@ import {
AI_TOOL_WIKIPEDIA_NODE_NAME,
BASIC_LLM_CHAIN_NODE_NAME,
EDIT_FIELDS_SET_NODE_NAME,
CHAT_TRIGGER_NODE_DISPLAY_NAME,
} from './../constants';

describe('Langchain Integration', () => {
Expand Down Expand Up @@ -331,4 +334,27 @@ describe('Langchain Integration', () => {

closeManualChatModal();
});

it('should auto-add chat trigger and basic LLM chain when adding LLM node', () => {
addNodeToCanvas(AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, true);

getConnectionBySourceAndTarget(
CHAT_TRIGGER_NODE_DISPLAY_NAME,
BASIC_LLM_CHAIN_NODE_NAME,
).should('exist');

getConnectionBySourceAndTarget(
AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME,
BASIC_LLM_CHAIN_NODE_NAME,
).should('exist');
getNodes().should('have.length', 3);
});

it('should not auto-add nodes if AI nodes are already present', () => {
addNodeToCanvas(AGENT_NODE_NAME, true);

addNodeToCanvas(AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, true);
getConnectionBySourceAndTarget(CHAT_TRIGGER_NODE_DISPLAY_NAME, AGENT_NODE_NAME).should('exist');
getNodes().should('have.length', 3);
});
});
36 changes: 36 additions & 0 deletions packages/@n8n/config/src/configs/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Config, Env, Nested } from '../decorators';

@Config
class MemoryConfig {
/** Max size of memory cache in bytes */
@Env('N8N_CACHE_MEMORY_MAX_SIZE')
maxSize = 3 * 1024 * 1024; // 3 MiB

/** Time to live (in milliseconds) for data cached in memory. */
@Env('N8N_CACHE_MEMORY_TTL')
ttl = 3600 * 1000; // 1 hour
}

@Config
class RedisConfig {
/** Prefix for cache keys in Redis. */
@Env('N8N_CACHE_REDIS_KEY_PREFIX')
prefix = 'redis';

/** Time to live (in milliseconds) for data cached in Redis. 0 for no TTL. */
@Env('N8N_CACHE_REDIS_TTL')
ttl = 3600 * 1000; // 1 hour
}

@Config
export class CacheConfig {
/** Backend to use for caching. */
@Env('N8N_CACHE_BACKEND')
backend: 'memory' | 'redis' | 'auto' = 'auto';

@Nested
memory: MemoryConfig;

@Nested
redis: RedisConfig;
}
8 changes: 4 additions & 4 deletions packages/@n8n/config/src/configs/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class CredentialsOverwrite {
* Format: { CREDENTIAL_NAME: { PARAMETER: VALUE }}
*/
@Env('CREDENTIALS_OVERWRITE_DATA')
readonly data: string = '{}';
data = '{}';

/** Internal API endpoint to fetch overwritten credential types from. */
@Env('CREDENTIALS_OVERWRITE_ENDPOINT')
readonly endpoint: string = '';
endpoint = '';
}

@Config
export class CredentialsConfig {
/** Default name for credentials */
@Env('CREDENTIALS_DEFAULT_NAME')
readonly defaultName: string = 'My credentials';
defaultName = 'My credentials';

@Nested
readonly overwrite: CredentialsOverwrite;
overwrite: CredentialsOverwrite;
}
60 changes: 30 additions & 30 deletions packages/@n8n/config/src/configs/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { Config, Env, Nested } from '../decorators';
class LoggingConfig {
/** Whether database logging is enabled. */
@Env('DB_LOGGING_ENABLED')
readonly enabled: boolean = false;
enabled = false;

/**
* Database logging level. Requires `DB_LOGGING_MAX_EXECUTION_TIME` to be higher than `0`.
*/
@Env('DB_LOGGING_OPTIONS')
readonly options: 'query' | 'error' | 'schema' | 'warn' | 'info' | 'log' | 'all' = 'error';
options: 'query' | 'error' | 'schema' | 'warn' | 'info' | 'log' | 'all' = 'error';

/**
* Only queries that exceed this time (ms) will be logged. Set `0` to disable.
*/
@Env('DB_LOGGING_MAX_EXECUTION_TIME')
readonly maxQueryExecutionTime: number = 0;
maxQueryExecutionTime = 0;
}

@Config
Expand All @@ -26,105 +26,105 @@ class PostgresSSLConfig {
* If `DB_POSTGRESDB_SSL_CA`, `DB_POSTGRESDB_SSL_CERT`, or `DB_POSTGRESDB_SSL_KEY` are defined, `DB_POSTGRESDB_SSL_ENABLED` defaults to `true`.
*/
@Env('DB_POSTGRESDB_SSL_ENABLED')
readonly enabled: boolean = false;
enabled = false;

/** SSL certificate authority */
@Env('DB_POSTGRESDB_SSL_CA')
readonly ca: string = '';
ca = '';

/** SSL certificate */
@Env('DB_POSTGRESDB_SSL_CERT')
readonly cert: string = '';
cert = '';

/** SSL key */
@Env('DB_POSTGRESDB_SSL_KEY')
readonly key: string = '';
key = '';

/** If unauthorized SSL connections should be rejected */
@Env('DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED')
readonly rejectUnauthorized: boolean = true;
rejectUnauthorized = true;
}

@Config
class PostgresConfig {
/** Postgres database name */
@Env('DB_POSTGRESDB_DATABASE')
database: string = 'n8n';
database = 'n8n';

/** Postgres database host */
@Env('DB_POSTGRESDB_HOST')
readonly host: string = 'localhost';
host = 'localhost';

/** Postgres database password */
@Env('DB_POSTGRESDB_PASSWORD')
readonly password: string = '';
password = '';

/** Postgres database port */
@Env('DB_POSTGRESDB_PORT')
readonly port: number = 5432;
port: number = 5432;

/** Postgres database user */
@Env('DB_POSTGRESDB_USER')
readonly user: string = 'postgres';
user = 'postgres';

/** Postgres database schema */
@Env('DB_POSTGRESDB_SCHEMA')
readonly schema: string = 'public';
schema = 'public';

/** Postgres database pool size */
@Env('DB_POSTGRESDB_POOL_SIZE')
readonly poolSize = 2;
poolSize = 2;

@Nested
readonly ssl: PostgresSSLConfig;
ssl: PostgresSSLConfig;
}

@Config
class MysqlConfig {
/** @deprecated MySQL database name */
@Env('DB_MYSQLDB_DATABASE')
database: string = 'n8n';
database = 'n8n';

/** MySQL database host */
@Env('DB_MYSQLDB_HOST')
readonly host: string = 'localhost';
host = 'localhost';

/** MySQL database password */
@Env('DB_MYSQLDB_PASSWORD')
readonly password: string = '';
password = '';

/** MySQL database port */
@Env('DB_MYSQLDB_PORT')
readonly port: number = 3306;
port: number = 3306;

/** MySQL database user */
@Env('DB_MYSQLDB_USER')
readonly user: string = 'root';
user = 'root';
}

@Config
class SqliteConfig {
/** SQLite database file name */
@Env('DB_SQLITE_DATABASE')
readonly database: string = 'database.sqlite';
database = 'database.sqlite';

/** SQLite database pool size. Set to `0` to disable pooling. */
@Env('DB_SQLITE_POOL_SIZE')
readonly poolSize: number = 0;
poolSize: number = 0;

/**
* Enable SQLite WAL mode.
*/
@Env('DB_SQLITE_ENABLE_WAL')
readonly enableWAL: boolean = this.poolSize > 1;
enableWAL = this.poolSize > 1;

/**
* Run `VACUUM` on startup to rebuild the database, reducing file size and optimizing indexes.
*
* @warning Long-running blocking operation that will increase startup time.
*/
@Env('DB_SQLITE_VACUUM_ON_STARTUP')
readonly executeVacuumOnStartup: boolean = false;
executeVacuumOnStartup = false;
}

@Config
Expand All @@ -135,17 +135,17 @@ export class DatabaseConfig {

/** Prefix for table names */
@Env('DB_TABLE_PREFIX')
readonly tablePrefix: string = '';
tablePrefix = '';

@Nested
readonly logging: LoggingConfig;
logging: LoggingConfig;

@Nested
readonly postgresdb: PostgresConfig;
postgresdb: PostgresConfig;

@Nested
readonly mysqldb: MysqlConfig;
mysqldb: MysqlConfig;

@Nested
readonly sqlite: SqliteConfig;
sqlite: SqliteConfig;
}
Loading

0 comments on commit a572adf

Please sign in to comment.