@yrpri/api 9.0.123 → 9.0.125
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.
|
|
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.
|
|
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/app.js
CHANGED
|
@@ -502,7 +502,15 @@ export class YourPrioritiesApi {
|
|
|
502
502
|
this.app.use(requestIp.mw());
|
|
503
503
|
this.app.use(bodyParser.json({ limit: "100mb", strict: false }));
|
|
504
504
|
this.app.use(bodyParser.urlencoded({ limit: "100mb", extended: true }));
|
|
505
|
-
|
|
505
|
+
if (process.env.ALLOWED_ORIGINS) {
|
|
506
|
+
this.app.use(cors({
|
|
507
|
+
origin: process.env.ALLOWED_ORIGINS.split(","),
|
|
508
|
+
credentials: true,
|
|
509
|
+
}));
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
this.app.use(cors());
|
|
513
|
+
}
|
|
506
514
|
this.app.use(compression());
|
|
507
515
|
this.app.set("views", __dirname + "/views");
|
|
508
516
|
this.app.set("view engine", "pug");
|
|
@@ -510,13 +518,19 @@ export class YourPrioritiesApi {
|
|
|
510
518
|
if (!process.env.SESSION_SECRET) {
|
|
511
519
|
throw new Error("SESSION_SECRET is not set");
|
|
512
520
|
}
|
|
521
|
+
let cookieValues = {
|
|
522
|
+
autoSubDomain: true,
|
|
523
|
+
};
|
|
524
|
+
if (process.env.ALLOWED_ORIGINS) {
|
|
525
|
+
cookieValues.sameSite = "none";
|
|
526
|
+
}
|
|
513
527
|
const sessionConfig = {
|
|
514
528
|
store: store,
|
|
515
529
|
name: "yrpri.sid",
|
|
516
530
|
secret: process.env.SESSION_SECRET,
|
|
517
531
|
resave: false,
|
|
518
532
|
proxy: process.env.USING_NGINX_PROXY ? true : undefined,
|
|
519
|
-
cookie:
|
|
533
|
+
cookie: cookieValues,
|
|
520
534
|
saveUninitialized: false,
|
|
521
535
|
};
|
|
522
536
|
if (this.app.get("env") === "production") {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PsAgentClass, PsAgent, PsAiModel } from "@policysynth/agents/dbModels/index.js";
|
|
1
|
+
import { initializeModels, PsAgentClass, PsAgent, PsAiModel, } from "@policysynth/agents/dbModels/index.js";
|
|
2
2
|
import models from "../../models/index.cjs";
|
|
3
3
|
import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
4
4
|
(async () => {
|
|
@@ -14,7 +14,8 @@ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
|
14
14
|
process.exit(1);
|
|
15
15
|
}
|
|
16
16
|
try {
|
|
17
|
-
await
|
|
17
|
+
await initializeModels();
|
|
18
|
+
await NewAiModelSetup.seedAiModels(1);
|
|
18
19
|
const domain = await models.Domain.findByPk(domainId);
|
|
19
20
|
if (!domain) {
|
|
20
21
|
throw new Error(`Domain ${domainId} not found`);
|
|
@@ -40,7 +41,29 @@ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
|
40
41
|
user_agent: "generateAgentWorkflowTemplateFromAgentClass.ts",
|
|
41
42
|
configuration: { groupType: 3, agents: {} },
|
|
42
43
|
});
|
|
43
|
-
// Create
|
|
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
|
|
44
67
|
const agentClass = await PsAgentClass.findByPk(agentClassId);
|
|
45
68
|
if (!agentClass) {
|
|
46
69
|
throw new Error(`PsAgentClass ${agentClassId} not found`);
|
|
@@ -49,6 +72,7 @@ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
|
49
72
|
user_id: agentClass.user_id,
|
|
50
73
|
class_id: agentClass.id,
|
|
51
74
|
group_id: group.id,
|
|
75
|
+
parent_agent_id: topLevelAgent.id,
|
|
52
76
|
configuration: {},
|
|
53
77
|
});
|
|
54
78
|
// Add Gemini 2.5 Pro Preview 2 model
|
|
@@ -71,11 +95,7 @@ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
|
|
|
71
95
|
else {
|
|
72
96
|
throw new Error("Gemini 2.0 Flash model not found");
|
|
73
97
|
}
|
|
74
|
-
|
|
75
|
-
group.configuration.agents = { topLevelAgentId: psAgent.id };
|
|
76
|
-
group.changed("configuration", true);
|
|
77
|
-
await group.save();
|
|
78
|
-
console.log(`Created community ${community.id}, group ${group.id}, agent ${psAgent.id}`);
|
|
98
|
+
console.log(`Created community ${community.id}, group ${group.id}, top-level agent ${topLevelAgent.id}, working agent ${psAgent.id}`);
|
|
79
99
|
}
|
|
80
100
|
catch (error) {
|
|
81
101
|
console.error(error);
|