@yrpri/api 9.0.136 → 9.0.138

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.
@@ -685,7 +685,7 @@ export class NewAiModelSetup {
685
685
  where: { name: "Gemini 2.5 Flash Preview 1" },
686
686
  });
687
687
  const gemini25FlashPreview1Config = {
688
- type: PsAiModelType.TextReasoning,
688
+ type: PsAiModelType.Text,
689
689
  modelSize: PsAiModelSize.Medium,
690
690
  provider: "google",
691
691
  prices: {
package/authorization.cjs CHANGED
@@ -934,6 +934,8 @@ auth.entity("group", function (req, done) {
934
934
  match = req.originalUrl.match(/agents\/(\w+)/);
935
935
  if (!match)
936
936
  match = req.originalUrl.match(/pdf_processing\/(\w+)/);
937
+ if (!match)
938
+ match = req.originalUrl.match(/docx_processing\/(\w+)/);
937
939
  if (!match)
938
940
  match = req.originalUrl.match(/feedback\/(\w+)/);
939
941
  if (!match)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.136",
3
+ "version": "9.0.138",
4
4
  "license": "MIT",
5
5
  "author": "Robert Bjarnason & Citizens Foundation",
6
6
  "repository": {
@@ -1,6 +1,7 @@
1
1
  import { initializeModels, PsAgent, PsAiModel, } from "@policysynth/agents/dbModels/index.js";
2
- import { PsAiModelSize, PsAiModelType } from "@policysynth/agents/aiModelTypes.js";
2
+ import { PsAiModelSize, PsAiModelType, } from "@policysynth/agents/aiModelTypes.js";
3
3
  import models from "../../models/index.cjs";
4
+ import { NewAiModelSetup } from "../../agents/managers/newAiModelSetup.js";
4
5
  (async () => {
5
6
  const [groupIdArg, sizeArg, typeArg, modelNameArg] = process.argv.slice(2);
6
7
  if (!groupIdArg || !sizeArg || !typeArg || !modelNameArg) {
@@ -53,16 +54,38 @@ import models from "../../models/index.cjs";
53
54
  if (!newModel) {
54
55
  throw new Error(`AI model with configuration.model ${modelNameArg} not found`);
55
56
  }
57
+ if (newModel.configuration?.type !== modelType ||
58
+ newModel.configuration?.modelSize !== size) {
59
+ throw new Error(`Model '${modelNameArg}' exists, but its configuration is ` +
60
+ `type=${newModel.configuration?.type ?? "∅"}, ` +
61
+ `size=${newModel.configuration?.modelSize ?? "∅"} – expected ` +
62
+ `${modelType}/${size}.`);
63
+ }
64
+ await NewAiModelSetup.setupApiKeysForGroup(group);
56
65
  const privateConfig = (group.private_access_configuration ?? []);
57
66
  for (const agent of subAgents) {
67
+ console.log(`Updating agent ${agent.id} to use model ${newModel.name}`);
58
68
  const currentModels = await agent.getAiModels();
69
+ console.log(`Current models: ${currentModels.length}`);
59
70
  for (const current of currentModels) {
60
71
  const cfg = current.configuration || {};
61
72
  if (cfg.modelSize === size && cfg.type === modelType) {
62
73
  await agent.removeAiModel(current);
63
74
  const entry = privateConfig.find((p) => p.aiModelId === current.id);
64
- if (entry)
75
+ if (entry) {
76
+ console.log(`Updating entry ${entry.id} to use model ${newModel.name}`);
65
77
  entry.aiModelId = newModel.id;
78
+ }
79
+ else {
80
+ console.log(`Adding entry for agent ${agent.id} to use model ${newModel.name}`);
81
+ privateConfig.push({
82
+ aiModelId: newModel.id,
83
+ agentId: agent.id,
84
+ });
85
+ }
86
+ }
87
+ else {
88
+ console.log(`Skipping model ${current.name} for agent ${agent.id} because it does not match size ${size} and type ${modelType}`);
66
89
  }
67
90
  }
68
91
  await agent.addAiModel(newModel);