@yrpri/api 9.0.88 → 9.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -419,6 +419,9 @@ var sendOneEmail = function (emailLocals, callback) {
419
419
  else {
420
420
  locale = "en";
421
421
  }
422
+ if (locale && typeof locale === 'string') {
423
+ locale = locale.toLowerCase();
424
+ }
422
425
  i18n.changeLanguage(locale, function (err, t) {
423
426
  seriesCallback(err);
424
427
  });
@@ -1,19 +1,13 @@
1
1
  import { OpenAI } from "openai";
2
2
  import { v4 as uuidv4 } from "uuid";
3
3
  import ioredis from "ioredis";
4
- let tlsConfig = {
5
- rejectUnauthorized: false,
6
- };
7
- if (!process.env.REDIS_URL || process.env.REDIS_URL.indexOf("localhost") > -1) {
8
- tlsConfig = undefined;
9
- }
10
4
  const DEBUG = false;
11
- //@ts-ignore
12
- const redis = new ioredis.default(process.env.REDIS_MEMORY_URL ||
5
+ const url = process.env.REDIS_MEMORY_URL ||
13
6
  process.env.REDIS_URL ||
14
- "redis://localhost:6379", {
15
- tls: tlsConfig,
16
- });
7
+ "redis://localhost:6379";
8
+ const tlsOptions = url.startsWith("rediss://")
9
+ ? { rejectUnauthorized: false }
10
+ : undefined;
17
11
  export class YpBaseChatBot {
18
12
  get redisKey() {
19
13
  return `${YpBaseChatBot.redisMemoryKeyPrefix}-${this.memoryId}`;
@@ -21,6 +15,12 @@ export class YpBaseChatBot {
21
15
  static loadMemoryFromRedis(memoryId) {
22
16
  return new Promise(async (resolve, reject) => {
23
17
  try {
18
+ //@ts-ignore
19
+ const redis = new ioredis.default(process.env.REDIS_MEMORY_URL ||
20
+ process.env.REDIS_URL ||
21
+ "redis://localhost:6379", {
22
+ tls: tlsOptions,
23
+ });
24
24
  const memoryString = await redis.get(`${YpBaseChatBot.redisMemoryKeyPrefix}-${memoryId}`);
25
25
  if (memoryString) {
26
26
  const memory = JSON.parse(memoryString);
@@ -42,7 +42,7 @@ export class YpBaseChatBot {
42
42
  loadMemory() {
43
43
  return new Promise(async (resolve, reject) => {
44
44
  try {
45
- const memoryString = await redis.get(this.redisKey);
45
+ const memoryString = await this.redis.get(this.redisKey);
46
46
  if (memoryString) {
47
47
  const memory = JSON.parse(memoryString);
48
48
  resolve(memory);
@@ -62,6 +62,12 @@ export class YpBaseChatBot {
62
62
  this.maxTokens = 16000;
63
63
  this.llmModel = "gpt-4o";
64
64
  this.persistMemory = false;
65
+ //@ts-ignore
66
+ this.redis = new ioredis.default(process.env.REDIS_MEMORY_URL ||
67
+ process.env.REDIS_URL ||
68
+ "redis://localhost:6379", {
69
+ tls: tlsOptions,
70
+ });
65
71
  this.wsClientId = wsClientId;
66
72
  this.wsClientSocket = wsClients.get(this.wsClientId);
67
73
  this.openaiClient = new OpenAI({
@@ -102,7 +108,7 @@ export class YpBaseChatBot {
102
108
  async saveMemory() {
103
109
  if (this.memory) {
104
110
  try {
105
- await redis.set(this.redisKey, JSON.stringify(this.memory));
111
+ await this.redis.set(this.redisKey, JSON.stringify(this.memory));
106
112
  console.log(`Saved memory to redis: ${this.redisKey}`);
107
113
  }
108
114
  catch (error) {
@@ -66,7 +66,7 @@ class YpQueue {
66
66
  }).on('completed', function (job, result) {
67
67
  log.info('JC', { id: job.id, name: job.name });
68
68
  }).on('failed', function (job, error) {
69
- log.error('Job Failed', { id: job.id, name: job.name, data: job.data, error });
69
+ log.error('Job Failed', { id: job ? job.id : null, name: job ? job.name : null, data: job ? job.data : null, error });
70
70
  }).on('resumed', function (job) {
71
71
  log.info('Job Removed', { id: job.id });
72
72
  }).on('waiting', function (jobId) {
@@ -22,25 +22,30 @@ export class YpBaseAssistant extends YpBaseChatBot {
22
22
  this.toolCallTimeout = 30000; // 30 seconds
23
23
  this.maxModeTransitions = 10;
24
24
  this.modelName = "gpt-4o";
25
- this.defaultSystemPrompt = `# Basic instructions
25
+ this.defaultSystemPrompt = `<coreImportantSystemInstructions>
26
26
  You are a helpful, witty, and friendly AI. Act like a human, but remember that you aren't a human and that you can't do human things in the real world.
27
27
  Your voice and personality should be warm and engaging, with a lively and playful tone. Talk quickly.
28
28
  If interacting in a non-English language, start by using the standard accent or dialect familiar to the user.
29
29
  You should always call a function/tool if you can to help the user with their request.
30
30
  Never try to start workflows without using functions/tools, using some tools will unlock other function/tools that might help the user with their request.
31
31
  Functions/tools will become available to you as the user progresses through the workflow.
32
- Make sure that the user is subscribed to the agent before you start a workflow.
32
+ Make sure that the user logged in and is subscribed to the agent before you start a workflow.
33
33
  Never list out the available agents using text or markdown, the user already sees the list of agents available for subscription in the UI.
34
- You will not be able to complete the request for the user except using tools/functions at each step.
34
+ You will not be able to start the workflow for the user except using tools/functions at each step.
35
+ Never engage in longish back and fourth conversations with the user if a workflow has not started, lead the user towards using the tools available as much as possible, politely.
36
+ Never engage in off topic conversations, always politely steer the conversation back to the workflow.
37
+ </coreImportantSystemInstructions>
35
38
 
36
- # Typical start of a user workflow is:
39
+ <typicalWorkflowStepsForStartingAnAgentWorkflow>
37
40
  1) The user chooses an agent to subscribe to using the direct connect to the agent the user chooses. It's only possible to subscribe to the agent after the user has connected directly to the agent.
38
41
  2) The agent offers to show the user a workflow overview, with a tool and then informs the user about the subscription process.
39
42
  3) The user logs in or creates an account, if not logged in.
40
43
  4) The user verbally confirms a subscription to the agent using a function/tool.
41
44
  5) The user fills out the configuration UI widget.
42
45
  6) The user submits from the configuration UI widget.
43
- 7) The user starts the workflow.`;
46
+ 7) The user starts the workflow run.
47
+ </typicalWorkflowStepsForStartingAnAgentWorkflow>
48
+ `;
44
49
  this.voiceEnabled = false;
45
50
  this.domainId = domainId;
46
51
  if (!domainId) {
@@ -479,7 +484,7 @@ You will not be able to complete the request for the user except using tools/fun
479
484
  console.error(`No current mode found: ${this.memory.currentMode}`);
480
485
  return this.defaultSystemPrompt;
481
486
  }
482
- return `${this.defaultSystemPrompt}\n\n# Current agent instructions:\n${currentMode.systemPrompt}`;
487
+ return `${this.defaultSystemPrompt}\n\n<furtherAgentInstructions>\n${currentMode.systemPrompt}\n</furtherAgentInstructions>`;
483
488
  }
484
489
  sendAvatarUrlChange(url, avatarName) {
485
490
  this.wsClientSocket.send(JSON.stringify({
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import express from "express";
3
2
  import { AgentQueueManager } from "@policysynth/agents/operations/agentQueueManager.js";
4
3
  import { AgentCostManager } from "@policysynth/agents/operations/agentCostsManager.js";
@@ -8,53 +7,14 @@ import { AgentRegistryManager } from "@policysynth/agents/operations/agentRegist
8
7
  import { PsAiModel } from "@policysynth/agents/dbModels/aiModel.js";
9
8
  import auth from "../../authorization.cjs";
10
9
  import models from "../../models/index.cjs";
11
- import { PsAiModelSize, PsAiModelType, } from "@policysynth/agents/aiModelTypes.js";
12
- import { PsAgentClass } from "@policysynth/agents/dbModels/agentClass.js";
13
- import { PsAgent } from "@policysynth/agents/dbModels/agent.js";
14
- import { PsAgentAuditLog } from "@policysynth/agents/dbModels/agentAuditLog.js";
15
- import { PsAgentConnector } from "@policysynth/agents/dbModels/agentConnector.js";
16
- import { PsAgentConnectorClass } from "@policysynth/agents/dbModels/agentConnectorClass.js";
17
- import { PsAgentRegistry } from "@policysynth/agents/dbModels/agentRegistry.js";
18
- import { PsExternalApiUsage } from "@policysynth/agents/dbModels/externalApiUsage.js";
19
- import { PsExternalApi } from "@policysynth/agents/dbModels/externalApis.js";
20
- import { PsModelUsage } from "@policysynth/agents/dbModels/modelUsage.js";
21
- import { sequelize as psSequelize } from "@policysynth/agents/dbModels/index.js";
22
- import { PsAgentClassCategories } from "@policysynth/agents/agentCategories.js";
10
+ import { NewAiModelSetup } from "../managers/newAiModelSetup.js";
23
11
  const dbModels = models;
24
12
  const Group = dbModels.Group;
25
13
  const User = dbModels.User;
26
- const psModels = {
27
- PsAgentClass,
28
- PsExternalApiUsage,
29
- PsModelUsage,
30
- PsAgentConnector,
31
- PsAgent,
32
- PsAgentAuditLog,
33
- PsAgentConnectorClass,
34
- PsAgentRegistry,
35
- PsAiModel,
36
- PsExternalApi,
37
- };
38
14
  export class PolicySynthAgentsController {
39
15
  constructor(wsClients) {
40
16
  this.path = "/api/agents";
41
17
  this.router = express.Router();
42
- this.initializeModels = async () => {
43
- try {
44
- console.log(`All Models Loaded Init`);
45
- // Call associate method to set up associations
46
- for (const modelName of Object.keys(psModels)) {
47
- if (psModels[modelName].associate) {
48
- await psModels[modelName].associate(psSequelize.models);
49
- }
50
- }
51
- console.log("All models initialized successfully.");
52
- }
53
- catch (error) {
54
- console.error("Error initializing models:", error);
55
- process.exit(1);
56
- }
57
- };
58
18
  this.replaceAgentMemory = async (req, res) => {
59
19
  try {
60
20
  const { groupId, agentId } = req.params;
@@ -69,12 +29,16 @@ export class PolicySynthAgentsController {
69
29
  }
70
30
  catch (jsonError) {
71
31
  console.log(`Received invalid JSON for agent ${agentId}`);
72
- return res.status(400).json({ error: "Invalid JSON format for memory" });
32
+ return res
33
+ .status(400)
34
+ .json({ error: "Invalid JSON format for memory" });
73
35
  }
74
36
  const memoryKey = await this.agentManager.getSubAgentMemoryKey(groupId, parseInt(agentId));
75
37
  if (!memoryKey) {
76
38
  console.log(`Memory key not found for agent ${agentId}`);
77
- return res.status(404).json({ error: "Memory key not found for the specified agent" });
39
+ return res
40
+ .status(404)
41
+ .json({ error: "Memory key not found for the specified agent" });
78
42
  }
79
43
  console.log(`Memory key found: ${memoryKey}`);
80
44
  await req.redisClient.set(memoryKey, JSON.stringify(memory));
@@ -101,7 +65,9 @@ export class PolicySynthAgentsController {
101
65
  }
102
66
  try {
103
67
  await this.agentConnectorManager.addExistingConnector(parseInt(groupId), parseInt(agentId), parseInt(connectorId), type);
104
- res.status(200).json({ message: `Existing ${connectorId} connector added successfully` });
68
+ res.status(200).json({
69
+ message: `Existing ${connectorId} connector added successfully`,
70
+ });
105
71
  }
106
72
  catch (error) {
107
73
  console.error(`Error adding existing ${connectorId} connector:`, error);
@@ -117,21 +83,20 @@ export class PolicySynthAgentsController {
117
83
  try {
118
84
  const { groupId, agentId } = req.params;
119
85
  console.log(`Attempting to get memory for agent ${agentId} in group ${groupId}`);
120
- // Get the memory key for the specified agent
121
86
  const memoryKey = await this.agentManager.getSubAgentMemoryKey(groupId, parseInt(agentId));
122
87
  if (!memoryKey) {
123
88
  console.log(`Memory key not found for agent ${agentId}`);
124
- return res.status(404).json({ error: "Memory key not found for the specified agent" });
89
+ return res
90
+ .status(404)
91
+ .json({ error: "Memory key not found for the specified agent" });
125
92
  }
126
93
  console.log(`Memory key found: ${memoryKey}`);
127
- // Use the Redis client to get the memory contents
128
94
  const memoryContents = await req.redisClient.get(memoryKey);
129
95
  if (!memoryContents) {
130
96
  console.log(`Memory contents not found for key ${memoryKey}`);
131
97
  return res.status(404).json({ error: "Memory contents not found" });
132
98
  }
133
99
  console.log(`Memory contents retrieved successfully`);
134
- // Parse the memory contents (assuming it's stored as JSON)
135
100
  const parsedMemoryContents = JSON.parse(memoryContents);
136
101
  res.json(parsedMemoryContents);
137
102
  }
@@ -394,261 +359,17 @@ export class PolicySynthAgentsController {
394
359
  this.agentConnectorManager = new AgentConnectorManager();
395
360
  this.agentRegistryManager = new AgentRegistryManager();
396
361
  this.initializeRoutes();
397
- this.initializeModels();
398
- this.setupAiModels();
362
+ // Call our separated model setup methods.
363
+ NewAiModelSetup.initializeModels();
364
+ // Using a hardcoded userId (1) for seeding test AI models.
365
+ NewAiModelSetup.setupAiModels(1);
399
366
  }
400
- async setupAiModels() {
401
- setTimeout(async () => {
402
- console.log("Seeding test AI models");
403
- await this.seedTestAiModels(1);
404
- }, 100);
405
- }
406
- async seedTestAiModels(userId) {
407
- const testModel = await PsAiModel.findOne({
408
- where: {
409
- name: "Anthropic Sonnet 3.5",
410
- },
411
- });
412
- if (!testModel) {
413
- const anthropicSonnetConfig = {
414
- type: PsAiModelType.Text,
415
- modelSize: PsAiModelSize.Medium,
416
- provider: "anthropic",
417
- prices: {
418
- costInTokensPerMillion: 3,
419
- costOutTokensPerMillion: 15,
420
- currency: "USD",
421
- },
422
- maxTokensOut: 8000,
423
- defaultTemperature: 0.7,
424
- model: "claude-3-5-sonnet-20240620",
425
- active: true,
426
- };
427
- const anthropicSonnet = await PsAiModel.create({
428
- name: "Anthropic Sonnet 3.5",
429
- organization_id: 1,
430
- user_id: userId,
431
- configuration: anthropicSonnetConfig,
432
- });
433
- console.log("Created test AI model:", anthropicSonnet);
434
- const openAiGpt4oConfig = {
435
- type: PsAiModelType.Text,
436
- modelSize: PsAiModelSize.Medium,
437
- provider: "openai",
438
- prices: {
439
- costInTokensPerMillion: 5,
440
- costOutTokensPerMillion: 15,
441
- currency: "USD",
442
- },
443
- maxTokensOut: 4096,
444
- defaultTemperature: 0.7,
445
- model: "gpt-4o",
446
- active: true,
447
- };
448
- const openAiGpt4oMiniConfig = {
449
- type: PsAiModelType.Text,
450
- modelSize: PsAiModelSize.Small,
451
- provider: "openai",
452
- prices: {
453
- costInTokensPerMillion: 0.15,
454
- costOutTokensPerMillion: 0.6,
455
- currency: "USD",
456
- },
457
- maxTokensOut: 16000,
458
- defaultTemperature: 0.0,
459
- model: "gpt-4o-mini",
460
- active: true,
461
- };
462
- const openAiGpt4 = await PsAiModel.create({
463
- name: "GPT-4o",
464
- organization_id: 1,
465
- user_id: userId,
466
- configuration: openAiGpt4oConfig,
467
- });
468
- console.log("Created test AI model:", openAiGpt4);
469
- const openAiGpt4Mini = await PsAiModel.create({
470
- name: "GPT-4o Mini",
471
- organization_id: 1,
472
- user_id: userId,
473
- configuration: openAiGpt4oMiniConfig,
474
- });
475
- console.log("Created test AI model:", openAiGpt4Mini);
476
- const topLevelAgentClassConfig = {
477
- category: PsAgentClassCategories.PolicySynthTopLevel,
478
- subCategory: "group",
479
- hasPublicAccess: true,
480
- description: "A top-level agent that coordinates other agents",
481
- queueName: "noqueue",
482
- imageUrl: "https://yrpri-eu-direct-assets.s3.eu-west-1.amazonaws.com/topLevelAgent.png",
483
- iconName: "coordinator",
484
- capabilities: [
485
- "process coordination",
486
- "task management",
487
- "result aggregation",
488
- ],
489
- questions: [],
490
- requestedAiModelSizes: ["large", "medium", "small"],
491
- supportedConnectors: [],
492
- };
493
- await PsAgentClass.create({
494
- class_base_id: "c375c1fb-58ca-4372-a567-0e02b2c3d479",
495
- name: "Operations",
496
- version: 1,
497
- available: true,
498
- configuration: topLevelAgentClassConfig,
499
- user_id: userId,
500
- });
501
- }
502
- else {
503
- console.log("Test AI models already exist");
504
- }
505
- const testOMiniModel = await PsAiModel.findOne({
506
- where: {
507
- name: "o1 Mini",
508
- },
509
- });
510
- if (!testOMiniModel) {
511
- const openAio1MiniConfig = {
512
- type: PsAiModelType.TextReasoning,
513
- modelSize: PsAiModelSize.Small,
514
- provider: "openai",
515
- prices: {
516
- costInTokensPerMillion: 3.0,
517
- costOutTokensPerMillion: 12.0,
518
- currency: "USD",
519
- },
520
- maxTokensOut: 32000,
521
- defaultTemperature: 0.0,
522
- model: "o1-mini",
523
- active: true,
524
- };
525
- const openAio1Mini = await PsAiModel.create({
526
- name: "o1 Mini",
527
- organization_id: 1,
528
- user_id: userId,
529
- configuration: openAio1MiniConfig,
530
- });
531
- }
532
- else {
533
- console.log("Test O models already exist");
534
- }
535
- const testOPreviewModel = await PsAiModel.findOne({
536
- where: {
537
- name: "o1 Preview",
538
- },
539
- });
540
- if (!testOPreviewModel) {
541
- const openAio1PreviewConfig = {
542
- type: PsAiModelType.TextReasoning,
543
- modelSize: PsAiModelSize.Medium,
544
- provider: "openai",
545
- prices: {
546
- costInTokensPerMillion: 15.0,
547
- costOutTokensPerMillion: 60.0,
548
- currency: "USD",
549
- },
550
- maxTokensOut: 32000,
551
- defaultTemperature: 0.0,
552
- model: "o1-preview",
553
- active: true,
554
- };
555
- const openAio1Preview = await PsAiModel.create({
556
- name: "o1 Preview",
557
- organization_id: 1,
558
- user_id: userId,
559
- configuration: openAio1PreviewConfig,
560
- });
561
- }
562
- else {
563
- console.log("Test O preview models already exist");
564
- }
565
- const testO1712Model = await PsAiModel.findOne({
566
- where: {
567
- name: "o1 24",
568
- },
569
- });
570
- if (!testO1712Model) {
571
- const openAio11712Config = {
572
- type: PsAiModelType.TextReasoning,
573
- modelSize: PsAiModelSize.Medium,
574
- provider: "openai",
575
- prices: {
576
- costInTokensPerMillion: 15.0,
577
- costOutTokensPerMillion: 60.0,
578
- currency: "USD",
579
- },
580
- maxTokensOut: 100000,
581
- defaultTemperature: 0.0,
582
- model: "o1-2024-12-17",
583
- active: true,
584
- };
585
- const openAio11712 = await PsAiModel.create({
586
- name: "o1 24",
587
- organization_id: 1,
588
- user_id: userId,
589
- configuration: openAio11712Config,
590
- });
591
- }
592
- else {
593
- console.log("Test o1 1712 models already exist");
594
- }
595
- const geminiProModel = await PsAiModel.findOne({
596
- where: {
597
- name: "Gemini 1.5 Pro 2",
598
- },
599
- });
600
- if (!geminiProModel) {
601
- const geminiProConfig = {
602
- type: PsAiModelType.Text,
603
- modelSize: PsAiModelSize.Medium,
604
- provider: "google",
605
- prices: {
606
- costInTokensPerMillion: 1.25,
607
- costOutTokensPerMillion: 5.0,
608
- currency: "USD",
609
- },
610
- maxTokensOut: 8192,
611
- defaultTemperature: 0.0,
612
- model: "gemini-1.5-pro-002",
613
- active: true,
614
- };
615
- const geminiPro = await PsAiModel.create({
616
- name: "Gemini 1.5 Pro 2",
617
- organization_id: 1,
618
- user_id: userId,
619
- configuration: geminiProConfig,
620
- });
621
- }
622
- else {
623
- console.log("Gemini 1.5 Pro 2 models already exist");
624
- }
625
- const geminiPro15FlashModel = await PsAiModel.findOne({
626
- where: {
627
- name: "Gemini 1.5 Flash 2",
628
- },
629
- });
630
- if (!geminiPro15FlashModel) {
631
- const geminiPro15FlashConfig = {
632
- type: PsAiModelType.Text,
633
- modelSize: PsAiModelSize.Small,
634
- provider: "google",
635
- prices: {
636
- costInTokensPerMillion: 0.075,
637
- costOutTokensPerMillion: 0.3,
638
- currency: "USD",
639
- },
640
- maxTokensOut: 8192,
641
- defaultTemperature: 0.0,
642
- model: "gemini-1.5-flash-002",
643
- active: true,
644
- };
645
- const geminiPro15Flash = await PsAiModel.create({
646
- name: "Gemini 1.5 Flash 2",
647
- organization_id: 1,
648
- user_id: userId,
649
- configuration: geminiPro15FlashConfig,
650
- });
651
- }
367
+ /**
368
+ * A proxy for setting up API keys for a group.
369
+ * @param group The group instance to configure
370
+ */
371
+ static async setupApiKeysForGroup(group) {
372
+ return NewAiModelSetup.setupApiKeysForGroup(group);
652
373
  }
653
374
  initializeRoutes() {
654
375
  this.router.get("/:groupId", auth.can("view group"), this.getAgent);
@@ -672,77 +393,3 @@ export class PolicySynthAgentsController {
672
393
  this.router.post("/:groupId/:agentId/:type(input|output)Connectors/existing", auth.can("edit group"), this.addExistingConnector);
673
394
  }
674
395
  }
675
- _a = PolicySynthAgentsController;
676
- PolicySynthAgentsController.setupApiKeysForGroup = async (group) => {
677
- const findLatestActiveModel = async (name) => {
678
- return await PsAiModel.findOne({
679
- where: {
680
- name,
681
- configuration: {
682
- active: true
683
- }
684
- },
685
- order: [['created_at', 'DESC']],
686
- });
687
- };
688
- const anthropicSonnet = await findLatestActiveModel("Anthropic Sonnet 3.5");
689
- const openAiGpt4 = await findLatestActiveModel("GPT-4o");
690
- const openAiGpt4Mini = await findLatestActiveModel("GPT-4o Mini");
691
- const geminiPro = await findLatestActiveModel("Gemini 1.5 Pro 2");
692
- const geminiPro15Flash = await findLatestActiveModel("Gemini 1.5 Flash 2");
693
- const openAio1Preview = await findLatestActiveModel("o1 Preview");
694
- const openAio1Mini = await findLatestActiveModel("o1 Mini");
695
- const openAio11712 = await findLatestActiveModel("o1 24");
696
- const groupAccessConfig = [];
697
- if (anthropicSonnet && process.env.ANTHROPIC_CLAUDE_API_KEY) {
698
- groupAccessConfig.push({
699
- aiModelId: anthropicSonnet.id,
700
- apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
701
- });
702
- }
703
- if (openAiGpt4 && process.env.OPENAI_API_KEY) {
704
- groupAccessConfig.push({
705
- aiModelId: openAiGpt4.id,
706
- apiKey: process.env.OPENAI_API_KEY,
707
- });
708
- }
709
- if (openAiGpt4Mini && process.env.OPENAI_API_KEY) {
710
- groupAccessConfig.push({
711
- aiModelId: openAiGpt4Mini.id,
712
- apiKey: process.env.OPENAI_API_KEY,
713
- });
714
- }
715
- if (openAio1Preview && process.env.OPENAI_API_KEY) {
716
- groupAccessConfig.push({
717
- aiModelId: openAio1Preview.id,
718
- apiKey: process.env.OPENAI_API_KEY,
719
- });
720
- }
721
- if (openAio1Mini && process.env.OPENAI_API_KEY) {
722
- groupAccessConfig.push({
723
- aiModelId: openAio1Mini.id,
724
- apiKey: process.env.OPENAI_API_KEY,
725
- });
726
- }
727
- if (geminiPro && process.env.GEMINI_API_KEY) {
728
- groupAccessConfig.push({
729
- aiModelId: geminiPro.id,
730
- apiKey: process.env.GEMINI_API_KEY,
731
- });
732
- }
733
- if (geminiPro15Flash && process.env.GEMINI_API_KEY) {
734
- groupAccessConfig.push({
735
- aiModelId: geminiPro15Flash.id,
736
- apiKey: process.env.GEMINI_API_KEY,
737
- });
738
- }
739
- if (openAio11712 && process.env.OPENAI_API_KEY) {
740
- groupAccessConfig.push({
741
- aiModelId: openAio11712.id,
742
- apiKey: process.env.OPENAI_API_KEY,
743
- });
744
- }
745
- group.set("private_access_configuration", groupAccessConfig);
746
- group.changed("private_access_configuration", true);
747
- await group.save();
748
- };