@yrpri/api 9.0.122 → 9.0.124

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.
@@ -575,7 +575,7 @@ export class NewAiModelSetup {
575
575
  });
576
576
  const gemini25ProPreview1Config = {
577
577
  type: PsAiModelType.TextReasoning,
578
- modelSize: PsAiModelSize.Medium,
578
+ modelSize: PsAiModelSize.Large,
579
579
  provider: "google",
580
580
  prices: {
581
581
  costInTokensPerMillion: 1.25,
@@ -612,7 +612,7 @@ export class NewAiModelSetup {
612
612
  });
613
613
  const gemini25ProConfig = {
614
614
  type: PsAiModelType.TextReasoning,
615
- modelSize: PsAiModelSize.Medium,
615
+ modelSize: PsAiModelSize.Large,
616
616
  provider: "google",
617
617
  prices: {
618
618
  costInTokensPerMillion: 1.25,
@@ -644,6 +644,43 @@ export class NewAiModelSetup {
644
644
  await gemini25ProPreview2.save();
645
645
  console.log("Google model already exists: Gemini 2.5 Pro");
646
646
  }
647
+ const gemini25FlashPreview1 = await PsAiModel.findOne({
648
+ where: { name: "Gemini 2.5 Flash Preview 1" },
649
+ });
650
+ const gemini25FlashPreview1Config = {
651
+ type: PsAiModelType.TextReasoning,
652
+ modelSize: PsAiModelSize.Medium,
653
+ provider: "google",
654
+ prices: {
655
+ costInTokensPerMillion: 0.15,
656
+ costOutTokensPerMillion: 0.6,
657
+ costInCachedContextTokensPerMillion: 0.09,
658
+ longContextTokenThreshold: 200000,
659
+ longContextCostInTokensPerMillion: 0.3,
660
+ longContextCostInCachedContextTokensPerMillion: 0.21,
661
+ longContextCostOutTokensPerMillion: 2.4,
662
+ currency: "USD",
663
+ },
664
+ model: "gemini-2.5-flash-preview-05-20",
665
+ active: true,
666
+ maxTokensOut: 100000,
667
+ defaultTemperature: 0.0
668
+ };
669
+ if (!gemini25FlashPreview1) {
670
+ await PsAiModel.create({
671
+ name: "Gemini 2.5 Flash Preview 1",
672
+ organization_id: 1,
673
+ user_id: userId,
674
+ configuration: gemini25FlashPreview1Config,
675
+ });
676
+ console.log("Created Google model: Gemini 2.5 Flash Preview 1");
677
+ }
678
+ else {
679
+ gemini25FlashPreview1.set("configuration", gemini25FlashPreview1Config);
680
+ gemini25FlashPreview1.changed("configuration", true);
681
+ await gemini25FlashPreview1.save();
682
+ console.log("Google model already exists: Gemini 2.5 Pro");
683
+ }
647
684
  }
648
685
  /**
649
686
  * Master seeding function which calls the provider-specific functions
@@ -753,6 +790,7 @@ export class NewAiModelSetup {
753
790
  { name: "Gemini 2.0 Flash", envKey: "GEMINI_API_KEY" },
754
791
  { name: "Gemini 2.5 Pro Preview 1", envKey: "GEMINI_API_KEY" },
755
792
  { name: "Gemini 2.5 Pro Preview 2", envKey: "GEMINI_API_KEY" },
793
+ { name: "Gemini 2.5 Flash Preview 1", envKey: "GEMINI_API_KEY" },
756
794
  { name: "o1 24", envKey: "OPENAI_API_KEY" },
757
795
  { name: "o3 mini", envKey: "OPENAI_API_KEY" },
758
796
  { name: "o4 mini", envKey: "OPENAI_API_KEY" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.122",
3
+ "version": "9.0.124",
4
4
  "license": "MIT",
5
5
  "author": "Robert Bjarnason & Citizens Foundation",
6
6
  "repository": {
@@ -0,0 +1,106 @@
1
+ import { initializeModels, PsAgentClass, PsAgent, PsAiModel, } from "@policysynth/agents/dbModels/index.js";
2
+ import models from "../../models/index.cjs";
3
+ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
4
+ (async () => {
5
+ const [domainIdArg, agentClassIdArg] = process.argv.slice(2);
6
+ if (!domainIdArg || !agentClassIdArg) {
7
+ console.error("Usage: ts-node generateAgentWorkflowTemplateFromAgentClass.ts <domainId> <psAgentClassId>");
8
+ process.exit(1);
9
+ }
10
+ const domainId = Number(domainIdArg);
11
+ const agentClassId = Number(agentClassIdArg);
12
+ if (isNaN(domainId) || isNaN(agentClassId)) {
13
+ console.error("Both domainId and psAgentClassId must be valid numbers");
14
+ process.exit(1);
15
+ }
16
+ try {
17
+ await initializeModels();
18
+ await NewAiModelSetup.seedAiModels(1);
19
+ const domain = await models.Domain.findByPk(domainId);
20
+ if (!domain) {
21
+ throw new Error(`Domain ${domainId} not found`);
22
+ }
23
+ // Create Community
24
+ const community = await models.Community.create({
25
+ domain_id: domainId,
26
+ name: `Agent Workflow Template ${Date.now()}`,
27
+ hostname: `agent-workflow-${Date.now()}`,
28
+ access: 1,
29
+ user_id: 1,
30
+ ip_address: "127.0.0.1",
31
+ user_agent: "generateAgentWorkflowTemplateFromAgentClass.ts",
32
+ configuration: {},
33
+ });
34
+ // Create Workflow Group
35
+ const group = await models.Group.create({
36
+ community_id: community.id,
37
+ name: "Agent Workflow",
38
+ access: 0,
39
+ user_id: 1,
40
+ ip_address: "127.0.0.1",
41
+ user_agent: "generateAgentWorkflowTemplateFromAgentClass.ts",
42
+ configuration: { groupType: 3, agents: {} },
43
+ });
44
+ // Create top level agent for the workflow
45
+ const topLevelUuid = process.env.CLASS_ID_FOR_TOP_LEVEL_AGENT;
46
+ if (!topLevelUuid) {
47
+ throw new Error("CLASS_ID_FOR_TOP_LEVEL_AGENT environment variable not set");
48
+ }
49
+ const topLevelClass = await PsAgentClass.findOne({
50
+ where: { class_base_id: topLevelUuid },
51
+ });
52
+ if (!topLevelClass) {
53
+ throw new Error("Top level agent class not found");
54
+ }
55
+ const topLevelAgent = await PsAgent.create({
56
+ user_id: topLevelClass.user_id,
57
+ class_id: topLevelClass.id,
58
+ group_id: group.id,
59
+ configuration: { name: `${group.name} Top-Level Agent` },
60
+ });
61
+ // Update group configuration with top level agent id
62
+ group.configuration.agents = { topLevelAgentId: topLevelAgent.id };
63
+ group.changed("configuration", true);
64
+ await group.save();
65
+ await NewAiModelSetup.setupApiKeysForGroup(group);
66
+ // Create working agent from class and attach to top level agent
67
+ const agentClass = await PsAgentClass.findByPk(agentClassId);
68
+ if (!agentClass) {
69
+ throw new Error(`PsAgentClass ${agentClassId} not found`);
70
+ }
71
+ const psAgent = await PsAgent.create({
72
+ user_id: agentClass.user_id,
73
+ class_id: agentClass.id,
74
+ group_id: group.id,
75
+ parent_agent_id: topLevelAgent.id,
76
+ configuration: {},
77
+ });
78
+ // Add Gemini 2.5 Pro Preview 2 model
79
+ const geminiReasoning = await PsAiModel.findOne({
80
+ where: { name: "Gemini 2.5 Pro Preview 2" },
81
+ });
82
+ if (geminiReasoning) {
83
+ await psAgent.addAiModel(geminiReasoning);
84
+ }
85
+ else {
86
+ throw new Error("Gemini 2.5 Pro Preview 2 model not found");
87
+ }
88
+ // Add Gemini 2.0 Flash model
89
+ const geminiFlash = await PsAiModel.findOne({
90
+ where: { name: "Gemini 2.0 Flash" },
91
+ });
92
+ if (geminiFlash) {
93
+ await psAgent.addAiModel(geminiFlash);
94
+ }
95
+ else {
96
+ throw new Error("Gemini 2.0 Flash model not found");
97
+ }
98
+ console.log(`Created community ${community.id}, group ${group.id}, top-level agent ${topLevelAgent.id}, working agent ${psAgent.id}`);
99
+ }
100
+ catch (error) {
101
+ console.error(error);
102
+ }
103
+ finally {
104
+ await models.sequelize.close();
105
+ }
106
+ })();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import models from '../../models/index.cjs';
2
+ (async () => {
3
+ try {
4
+ const [userId, domainName, name] = process.argv.slice(2);
5
+ if (!domainName || !name) {
6
+ console.log('Usage: node createDomain.js <user_id> <domain_name> "<name>"');
7
+ process.exit(1);
8
+ }
9
+ const existing = await models.Domain.findOne({ where: { domain_name: domainName } });
10
+ if (existing) {
11
+ console.error(`Domain with domain_name ${domainName} already exists`);
12
+ process.exit(1);
13
+ }
14
+ const domain = await models.Domain.create({
15
+ domain_name: domainName,
16
+ name,
17
+ access: 1,
18
+ user_id: parseInt(userId),
19
+ ip_address: '127.0.0.1',
20
+ user_agent: 'cli-script',
21
+ default_locale: 'en',
22
+ configuration: {}
23
+ });
24
+ console.log(`Created domain ${domain.name} with id ${domain.id}`);
25
+ process.exit(0);
26
+ }
27
+ catch (err) {
28
+ console.error(err);
29
+ process.exit(1);
30
+ }
31
+ })();