Skip to content

Commit f712f39

Browse files
authored
Merge pull request #3076 from RedisInsight/feature/RI-5402-ai-assistant
Feature/ri 5402
2 parents 0e0dcf1 + a32d900 commit f712f39

File tree

580 files changed

+14827
-3030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

580 files changed

+14827
-3030
lines changed

configs/webpack.config.main.prod.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default merge(baseConfig, {
7171
// cloud auth
7272
RI_CLOUD_IDP_AUTHORIZE_URL: 'RI_CLOUD_IDP_AUTHORIZE_URL' in process.env ? process.env.RI_CLOUD_IDP_AUTHORIZE_URL: '',
7373
RI_CLOUD_IDP_TOKEN_URL: 'RI_CLOUD_IDP_TOKEN_URL' in process.env ? process.env.RI_CLOUD_IDP_TOKEN_URL: '',
74+
RI_CLOUD_IDP_REVOKE_TOKEN_URL: 'RI_CLOUD_IDP_REVOKE_TOKEN_URL' in process.env ? process.env.RI_CLOUD_IDP_REVOKE_TOKEN_URL: '',
7475
RI_CLOUD_IDP_ISSUER: 'RI_CLOUD_IDP_ISSUER' in process.env ? process.env.RI_CLOUD_IDP_ISSUER: '',
7576
RI_CLOUD_IDP_CLIENT_ID: 'RI_CLOUD_IDP_CLIENT_ID' in process.env ? process.env.RI_CLOUD_IDP_CLIENT_ID: '',
7677
RI_CLOUD_IDP_REDIRECT_URI: 'RI_CLOUD_IDP_REDIRECT_URI' in process.env ? process.env.RI_CLOUD_IDP_REDIRECT_URI: '',
@@ -79,6 +80,9 @@ export default merge(baseConfig, {
7980
RI_CLOUD_API_URL: 'RI_CLOUD_API_URL' in process.env ? process.env.RI_CLOUD_API_URL: '',
8081
RI_CLOUD_CAPI_URL: 'RI_CLOUD_CAPI_URL' in process.env ? process.env.RI_CLOUD_CAPI_URL: '',
8182
RI_CLOUD_API_TOKEN: 'RI_CLOUD_API_TOKEN' in process.env ? process.env.RI_CLOUD_API_TOKEN: '',
83+
RI_AI_CONVAI_TOKEN: 'RI_AI_CONVAI_TOKEN' in process.env ? process.env.RI_AI_CONVAI_TOKEN: '',
84+
RI_AI_QUERY_USER: 'RI_AI_QUERY_USER' in process.env ? process.env.RI_AI_QUERY_USER: '',
85+
RI_AI_QUERY_PASS: 'RI_AI_QUERY_PASS' in process.env ? process.env.RI_AI_QUERY_PASS: '',
8286
}),
8387

8488
new webpack.DefinePlugin({

redisinsight/api/config/default.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default {
4040
staticDir,
4141
defaultsDir,
4242
logs: join(homedir, 'logs'),
43+
customConfig: join(homedir, 'config.json'),
4344
defaultPlugins: join(staticDir, 'plugins'),
4445
customPlugins: join(homedir, 'plugins'),
4546
customTutorials: join(homedir, 'custom-tutorials'),
@@ -236,10 +237,12 @@ export default {
236237
jobIterationInterval: parseInt(process.env.RI_CLOUD_JOB_ITERATION_INTERVAL, 10) || 10_000, // 10 sec
237238
discoveryTimeout: parseInt(process.env.RI_CLOUD_DISCOVERY_TIMEOUT, 10) || 60 * 1000, // 1 min
238239
databaseConnectionTimeout: parseInt(process.env.RI_CLOUD_DATABASE_CONNECTION_TIMEOUT, 10) || 30 * 1000,
240+
renewTokensBeforeExpire: parseInt(process.env.RI_CLOUD_DATABASE_CONNECTION_TIMEOUT, 10) || 2 * 60_000, // 2min
239241
idp: {
240242
google: {
241243
authorizeUrl: process.env.RI_CLOUD_IDP_GOOGLE_AUTHORIZE_URL || process.env.RI_CLOUD_IDP_AUTHORIZE_URL,
242244
tokenUrl: process.env.RI_CLOUD_IDP_GOOGLE_TOKEN_URL || process.env.RI_CLOUD_IDP_TOKEN_URL,
245+
revokeTokenUrl: process.env.RI_CLOUD_IDP_GOOGLE_REVOKE_TOKEN_URL || process.env.RI_CLOUD_IDP_REVOKE_TOKEN_URL,
243246
issuer: process.env.RI_CLOUD_IDP_GOOGLE_ISSUER || process.env.RI_CLOUD_IDP_ISSUER,
244247
clientId: process.env.RI_CLOUD_IDP_GOOGLE_CLIENT_ID || process.env.RI_CLOUD_IDP_CLIENT_ID,
245248
redirectUri: process.env.RI_CLOUD_IDP_GOOGLE_REDIRECT_URI || process.env.RI_CLOUD_IDP_REDIRECT_URI,
@@ -248,11 +251,19 @@ export default {
248251
github: {
249252
authorizeUrl: process.env.RI_CLOUD_IDP_GH_AUTHORIZE_URL || process.env.RI_CLOUD_IDP_AUTHORIZE_URL,
250253
tokenUrl: process.env.RI_CLOUD_IDP_GH_TOKEN_URL || process.env.RI_CLOUD_IDP_TOKEN_URL,
254+
revokeTokenUrl: process.env.RI_CLOUD_IDP_GH_REVOKE_TOKEN_URL || process.env.RI_CLOUD_IDP_REVOKE_TOKEN_URL,
251255
issuer: process.env.RI_CLOUD_IDP_GH_ISSUER || process.env.RI_CLOUD_IDP_ISSUER,
252256
clientId: process.env.RI_CLOUD_IDP_GH_CLIENT_ID || process.env.RI_CLOUD_IDP_CLIENT_ID,
253257
redirectUri: process.env.RI_CLOUD_IDP_GH_REDIRECT_URI || process.env.RI_CLOUD_IDP_REDIRECT_URI,
254258
idp: process.env.RI_CLOUD_IDP_GH_ID,
255259
},
256260
},
257261
},
262+
ai: {
263+
convAiApiUrl: process.env.RI_AI_CONVAI_API_URL || 'https://staging.redis.io/convai/api',
264+
convAiToken: process.env.RI_AI_CONVAI_TOKEN,
265+
querySocketUrl: process.env.RI_AI_QUERY_SOCKET_URL || 'https://app-sm.k8s-cloudapi.sm-qa.qa.redislabs.com',
266+
querySocketPath: process.env.RI_AI_QUERY_SOCKET_PATH || '/api/v1/cloud-copilot-service/socket.io/',
267+
queryHistoryLimit: parseInt(process.env.RI_AI_QUERY_HISTORY_LIMIT, 10) || 20,
268+
},
258269
};

redisinsight/api/config/features-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": 2.46,
2+
"version": 2.4603,
33
"features": {
44
"insightsRecommendations": {
55
"flag": true,

redisinsight/api/config/ormconfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { FeatureEntity } from 'src/modules/feature/entities/feature.entity';
1919
import { FeaturesConfigEntity } from 'src/modules/feature/entities/features-config.entity';
2020
import { CloudDatabaseDetailsEntity } from 'src/modules/cloud/database/entities/cloud-database-details.entity';
2121
import { CloudCapiKeyEntity } from 'src/modules/cloud/capi-key/entity/cloud-capi-key.entity';
22+
import { AiQueryMessageEntity } from 'src/modules/ai/query/entities/ai-query.message.entity';
2223
import migrations from '../migration';
2324
import * as config from '../src/utils/config';
2425

@@ -48,6 +49,7 @@ const ormConfig = {
4849
FeaturesConfigEntity,
4950
CloudDatabaseDetailsEntity,
5051
CloudCapiKeyEntity,
52+
AiQueryMessageEntity,
5153
],
5254
migrations,
5355
};

redisinsight/api/config/production.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default {
1111
homedir,
1212
prevHomedir,
1313
logs: join(homedir, 'logs'),
14+
customConfig: join(homedir, 'config.json'),
1415
customPlugins: join(homedir, 'plugins'),
1516
customTutorials: join(homedir, 'custom-tutorials'),
1617
commands: join(homedir, 'commands'),
@@ -37,4 +38,7 @@ export default {
3738
cloud: {
3839
cApiUrl: process.env.RI_CLOUD_CAPI_URL || 'https://api.redislabs.com/v1',
3940
},
41+
ai: {
42+
convAiApiUrl: process.env.RI_AI_CONVAI_API_URL || 'https://redis.io/convai/api',
43+
},
4044
};

redisinsight/api/config/staging.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default {
1111
homedir,
1212
prevHomedir,
1313
logs: join(homedir, 'logs'),
14+
customConfig: join(homedir, 'config.json'),
1415
customPlugins: join(homedir, 'plugins'),
1516
customTutorials: join(homedir, 'custom-tutorials'),
1617
commands: join(homedir, 'commands'),

redisinsight/api/config/test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,37 @@ export default {
2121
url: process.env.RI_FEATURES_CONFIG_URL
2222
|| 'http://localhost:5551/remote/features-config.json',
2323
},
24+
cloud: {
25+
apiUrl: process.env.RI_CLOUD_API_URL || 'https://app-sm.k8s-cloudapi.sm-qa.qa.redislabs.com/api/v1',
26+
apiToken: process.env.RI_CLOUD_API_TOKEN || 'token',
27+
capiUrl: process.env.RI_CLOUD_CAPI_URL || 'https://api-k8s-cloudapi.qa.redislabs.com/v1',
28+
capiKeyName: process.env.RI_CLOUD_CAPI_KEY_NAME || 'RedisInsight',
29+
freeSubscriptionName: process.env.RI_CLOUD_FREE_SUBSCRIPTION_NAME || 'My free subscription',
30+
freeDatabaseName: process.env.RI_CLOUD_FREE_DATABASE_NAME || 'Redis-Stack-in-Redis-Enterprise-Cloud',
31+
defaultPlanRegion: process.env.RI_CLOUD_DEFAULT_PLAN_REGION || 'eu-west-1',
32+
jobIterationInterval: parseInt(process.env.RI_CLOUD_JOB_ITERATION_INTERVAL, 10) || 10_000, // 10 sec
33+
discoveryTimeout: parseInt(process.env.RI_CLOUD_DISCOVERY_TIMEOUT, 10) || 60 * 1000, // 1 min
34+
databaseConnectionTimeout: parseInt(process.env.RI_CLOUD_DATABASE_CONNECTION_TIMEOUT, 10) || 30 * 1000,
35+
renewTokensBeforeExpire: parseInt(process.env.RI_CLOUD_DATABASE_CONNECTION_TIMEOUT, 10) || 2 * 60_000, // 2min
36+
idp: {
37+
google: {
38+
authorizeUrl: 'oauth2/authorize',
39+
tokenUrl: 'oauth2/token',
40+
revokeTokenUrl: 'oauth2/revoke',
41+
issuer: 'https://authorization.server.com',
42+
clientId: 'cid_p6vA6A5tF36Jf6twH2cBOqtt7n',
43+
redirectUri: 'redisinsight:/cloud/oauth/callback',
44+
idp: 'test-google-idp',
45+
},
46+
github: {
47+
authorizeUrl: 'oauth2/authorize',
48+
tokenUrl: 'oauth2/token',
49+
revokeTokenUrl: 'oauth2/revoke',
50+
issuer: 'https://authorization.server.com',
51+
clientId: 'cid_p6vA6A5tF36Jf6twH2cBOqtt7n',
52+
redirectUri: 'redisinsight:/cloud/oauth/callback',
53+
idp: 'test-github-idp',
54+
},
55+
},
56+
},
2457
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class AiHistory1713515657364 implements MigrationInterface {
4+
name = 'AiHistory1713515657364'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE TABLE "ai_query_message" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "accountId" varchar NOT NULL, "type" varchar NOT NULL, "content" blob NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "encryption" varchar)`);
8+
await queryRunner.query(`CREATE INDEX "IDX_51d5d60bfc249e9a20443376e1" ON "ai_query_message" ("databaseId") `);
9+
await queryRunner.query(`CREATE INDEX "IDX_f0a6e0873ac71f323e9880b4a8" ON "ai_query_message" ("accountId") `);
10+
await queryRunner.query(`CREATE INDEX "IDX_5c051504f4efe6f20c5a7f64f6" ON "ai_query_message" ("createdAt") `);
11+
}
12+
13+
public async down(queryRunner: QueryRunner): Promise<void> {
14+
await queryRunner.query(`DROP INDEX "IDX_5c051504f4efe6f20c5a7f64f6"`);
15+
await queryRunner.query(`DROP INDEX "IDX_f0a6e0873ac71f323e9880b4a8"`);
16+
await queryRunner.query(`DROP INDEX "IDX_51d5d60bfc249e9a20443376e1"`);
17+
await queryRunner.query(`DROP TABLE "ai_query_message"`);
18+
}
19+
20+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class AiHistorySteps1714501203616 implements MigrationInterface {
4+
name = 'Migration1714501203616'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`DROP INDEX "IDX_5c051504f4efe6f20c5a7f64f6"`);
8+
await queryRunner.query(`DROP INDEX "IDX_f0a6e0873ac71f323e9880b4a8"`);
9+
await queryRunner.query(`DROP INDEX "IDX_51d5d60bfc249e9a20443376e1"`);
10+
await queryRunner.query(`CREATE TABLE "temporary_ai_query_message" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "accountId" varchar NOT NULL, "type" varchar NOT NULL, "content" blob NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "encryption" varchar, "steps" blob)`);
11+
await queryRunner.query(`INSERT INTO "temporary_ai_query_message"("id", "databaseId", "accountId", "type", "content", "createdAt", "encryption") SELECT "id", "databaseId", "accountId", "type", "content", "createdAt", "encryption" FROM "ai_query_message"`);
12+
await queryRunner.query(`DROP TABLE "ai_query_message"`);
13+
await queryRunner.query(`ALTER TABLE "temporary_ai_query_message" RENAME TO "ai_query_message"`);
14+
await queryRunner.query(`CREATE INDEX "IDX_5c051504f4efe6f20c5a7f64f6" ON "ai_query_message" ("createdAt") `);
15+
await queryRunner.query(`CREATE INDEX "IDX_f0a6e0873ac71f323e9880b4a8" ON "ai_query_message" ("accountId") `);
16+
await queryRunner.query(`CREATE INDEX "IDX_51d5d60bfc249e9a20443376e1" ON "ai_query_message" ("databaseId") `);
17+
}
18+
19+
public async down(queryRunner: QueryRunner): Promise<void> {
20+
await queryRunner.query(`DROP INDEX "IDX_51d5d60bfc249e9a20443376e1"`);
21+
await queryRunner.query(`DROP INDEX "IDX_f0a6e0873ac71f323e9880b4a8"`);
22+
await queryRunner.query(`DROP INDEX "IDX_5c051504f4efe6f20c5a7f64f6"`);
23+
await queryRunner.query(`ALTER TABLE "ai_query_message" RENAME TO "temporary_ai_query_message"`);
24+
await queryRunner.query(`CREATE TABLE "ai_query_message" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "accountId" varchar NOT NULL, "type" varchar NOT NULL, "content" blob NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "encryption" varchar)`);
25+
await queryRunner.query(`INSERT INTO "ai_query_message"("id", "databaseId", "accountId", "type", "content", "createdAt", "encryption") SELECT "id", "databaseId", "accountId", "type", "content", "createdAt", "encryption" FROM "temporary_ai_query_message"`);
26+
await queryRunner.query(`DROP TABLE "temporary_ai_query_message"`);
27+
await queryRunner.query(`CREATE INDEX "IDX_51d5d60bfc249e9a20443376e1" ON "ai_query_message" ("databaseId") `);
28+
await queryRunner.query(`CREATE INDEX "IDX_f0a6e0873ac71f323e9880b4a8" ON "ai_query_message" ("accountId") `);
29+
await queryRunner.query(`CREATE INDEX "IDX_5c051504f4efe6f20c5a7f64f6" ON "ai_query_message" ("createdAt") `);
30+
}
31+
32+
}

redisinsight/api/migration/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { CloudDatabaseDetails1687166457712 } from './1687166457712-cloud-databas
3838
import { FreeCloudDatabase1688989337247 } from './1688989337247-freeCloudDatabase';
3939
import { CloudCapiKeys1691061058385 } from './1691061058385-cloud-capi-keys';
4040
import { FeatureSso1691476419592 } from './1691476419592-feature-sso';
41+
import { AiHistory1713515657364 } from './1713515657364-ai-history';
42+
import { AiHistorySteps1714501203616 } from './1714501203616-ai-history-steps';
4143

4244
export default [
4345
initialMigration1614164490968,
@@ -80,4 +82,6 @@ export default [
8082
FreeCloudDatabase1688989337247,
8183
CloudCapiKeys1691061058385,
8284
FeatureSso1691476419592,
85+
AiHistory1713515657364,
86+
AiHistorySteps1714501203616,
8387
];

0 commit comments

Comments
 (0)