@contractspec/lib.content-gen 2.9.1 → 3.1.1

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.
@@ -922,11 +922,15 @@ class BlogGenerator {
922
922
  model;
923
923
  temperature;
924
924
  i18n;
925
+ modelSelector;
926
+ selectionContext;
925
927
  constructor(options) {
926
928
  this.llm = options?.llm;
927
929
  this.model = options?.model;
928
930
  this.temperature = options?.temperature ?? 0.4;
929
931
  this.i18n = createContentGenI18n(options?.locale);
932
+ this.modelSelector = options?.modelSelector;
933
+ this.selectionContext = options?.selectionContext;
930
934
  }
931
935
  async generate(brief) {
932
936
  if (this.llm) {
@@ -934,10 +938,23 @@ class BlogGenerator {
934
938
  }
935
939
  return this.generateDeterministic(brief);
936
940
  }
941
+ async resolveModel() {
942
+ if (this.model)
943
+ return this.model;
944
+ if (this.modelSelector) {
945
+ const ctx = this.selectionContext ?? {
946
+ taskDimension: "reasoning"
947
+ };
948
+ const result = await this.modelSelector.select(ctx);
949
+ return result.modelId;
950
+ }
951
+ return;
952
+ }
937
953
  async generateWithLlm(brief) {
938
954
  if (!this.llm) {
939
955
  return this.generateDeterministic(brief);
940
956
  }
957
+ const model = await this.resolveModel();
941
958
  const response = await this.llm.chat([
942
959
  {
943
960
  role: "system",
@@ -959,7 +976,7 @@ class BlogGenerator {
959
976
  }
960
977
  ], {
961
978
  responseFormat: "json",
962
- model: this.model,
979
+ model,
963
980
  temperature: this.temperature
964
981
  });
965
982
  const jsonPart = response.message.content.find((part) => ("text" in part));
@@ -922,11 +922,15 @@ class EmailCampaignGenerator {
922
922
  model;
923
923
  temperature;
924
924
  i18n;
925
+ modelSelector;
926
+ selectionContext;
925
927
  constructor(options) {
926
928
  this.llm = options?.llm;
927
929
  this.model = options?.model;
928
930
  this.temperature = options?.temperature ?? 0.6;
929
931
  this.i18n = createContentGenI18n(options?.locale);
932
+ this.modelSelector = options?.modelSelector;
933
+ this.selectionContext = options?.selectionContext;
930
934
  }
931
935
  async generate(input) {
932
936
  if (this.llm) {
@@ -936,9 +940,22 @@ class EmailCampaignGenerator {
936
940
  }
937
941
  return this.generateFallback(input);
938
942
  }
943
+ async resolveModel() {
944
+ if (this.model)
945
+ return this.model;
946
+ if (this.modelSelector) {
947
+ const ctx = this.selectionContext ?? {
948
+ taskDimension: "reasoning"
949
+ };
950
+ const result = await this.modelSelector.select(ctx);
951
+ return result.modelId;
952
+ }
953
+ return;
954
+ }
939
955
  async generateWithLlm(input) {
940
956
  if (!this.llm)
941
957
  return null;
958
+ const model = await this.resolveModel();
942
959
  const response = await this.llm.chat([
943
960
  {
944
961
  role: "system",
@@ -955,7 +972,7 @@ class EmailCampaignGenerator {
955
972
  }
956
973
  ], {
957
974
  responseFormat: "json",
958
- model: this.model,
975
+ model,
959
976
  temperature: this.temperature
960
977
  });
961
978
  const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
@@ -922,11 +922,15 @@ class BlogGenerator {
922
922
  model;
923
923
  temperature;
924
924
  i18n;
925
+ modelSelector;
926
+ selectionContext;
925
927
  constructor(options) {
926
928
  this.llm = options?.llm;
927
929
  this.model = options?.model;
928
930
  this.temperature = options?.temperature ?? 0.4;
929
931
  this.i18n = createContentGenI18n(options?.locale);
932
+ this.modelSelector = options?.modelSelector;
933
+ this.selectionContext = options?.selectionContext;
930
934
  }
931
935
  async generate(brief) {
932
936
  if (this.llm) {
@@ -934,10 +938,23 @@ class BlogGenerator {
934
938
  }
935
939
  return this.generateDeterministic(brief);
936
940
  }
941
+ async resolveModel() {
942
+ if (this.model)
943
+ return this.model;
944
+ if (this.modelSelector) {
945
+ const ctx = this.selectionContext ?? {
946
+ taskDimension: "reasoning"
947
+ };
948
+ const result = await this.modelSelector.select(ctx);
949
+ return result.modelId;
950
+ }
951
+ return;
952
+ }
937
953
  async generateWithLlm(brief) {
938
954
  if (!this.llm) {
939
955
  return this.generateDeterministic(brief);
940
956
  }
957
+ const model = await this.resolveModel();
941
958
  const response = await this.llm.chat([
942
959
  {
943
960
  role: "system",
@@ -959,7 +976,7 @@ class BlogGenerator {
959
976
  }
960
977
  ], {
961
978
  responseFormat: "json",
962
- model: this.model,
979
+ model,
963
980
  temperature: this.temperature
964
981
  });
965
982
  const jsonPart = response.message.content.find((part) => ("text" in part));
@@ -1021,11 +1038,15 @@ class EmailCampaignGenerator {
1021
1038
  model;
1022
1039
  temperature;
1023
1040
  i18n;
1041
+ modelSelector;
1042
+ selectionContext;
1024
1043
  constructor(options) {
1025
1044
  this.llm = options?.llm;
1026
1045
  this.model = options?.model;
1027
1046
  this.temperature = options?.temperature ?? 0.6;
1028
1047
  this.i18n = createContentGenI18n(options?.locale);
1048
+ this.modelSelector = options?.modelSelector;
1049
+ this.selectionContext = options?.selectionContext;
1029
1050
  }
1030
1051
  async generate(input) {
1031
1052
  if (this.llm) {
@@ -1035,9 +1056,22 @@ class EmailCampaignGenerator {
1035
1056
  }
1036
1057
  return this.generateFallback(input);
1037
1058
  }
1059
+ async resolveModel() {
1060
+ if (this.model)
1061
+ return this.model;
1062
+ if (this.modelSelector) {
1063
+ const ctx = this.selectionContext ?? {
1064
+ taskDimension: "reasoning"
1065
+ };
1066
+ const result = await this.modelSelector.select(ctx);
1067
+ return result.modelId;
1068
+ }
1069
+ return;
1070
+ }
1038
1071
  async generateWithLlm(input) {
1039
1072
  if (!this.llm)
1040
1073
  return null;
1074
+ const model = await this.resolveModel();
1041
1075
  const response = await this.llm.chat([
1042
1076
  {
1043
1077
  role: "system",
@@ -1054,7 +1088,7 @@ class EmailCampaignGenerator {
1054
1088
  }
1055
1089
  ], {
1056
1090
  responseFormat: "json",
1057
- model: this.model,
1091
+ model,
1058
1092
  temperature: this.temperature
1059
1093
  });
1060
1094
  const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
@@ -1150,11 +1184,15 @@ class LandingPageGenerator {
1150
1184
  llm;
1151
1185
  model;
1152
1186
  i18n;
1187
+ modelSelector;
1188
+ selectionContext;
1153
1189
  constructor(options) {
1154
1190
  this.options = options;
1155
1191
  this.llm = options?.llm;
1156
1192
  this.model = options?.model;
1157
1193
  this.i18n = createContentGenI18n(options?.locale);
1194
+ this.modelSelector = options?.modelSelector;
1195
+ this.selectionContext = options?.selectionContext;
1158
1196
  }
1159
1197
  async generate(brief) {
1160
1198
  if (this.llm) {
@@ -1162,10 +1200,21 @@ class LandingPageGenerator {
1162
1200
  }
1163
1201
  return this.generateFallback(brief);
1164
1202
  }
1203
+ async resolveModel() {
1204
+ if (this.model)
1205
+ return this.model;
1206
+ if (this.modelSelector) {
1207
+ const ctx = this.selectionContext ?? { taskDimension: "coding" };
1208
+ const result = await this.modelSelector.select(ctx);
1209
+ return result.modelId;
1210
+ }
1211
+ return;
1212
+ }
1165
1213
  async generateWithLlm(brief) {
1166
1214
  if (!this.llm) {
1167
1215
  return this.generateFallback(brief);
1168
1216
  }
1217
+ const model = await this.resolveModel();
1169
1218
  const response = await this.llm.chat([
1170
1219
  {
1171
1220
  role: "system",
@@ -1182,7 +1231,7 @@ class LandingPageGenerator {
1182
1231
  }
1183
1232
  ], {
1184
1233
  responseFormat: "json",
1185
- model: this.model,
1234
+ model,
1186
1235
  temperature: this.options?.temperature ?? 0.5
1187
1236
  });
1188
1237
  const part = response.message.content.find((chunk) => ("text" in chunk));
@@ -1245,10 +1294,14 @@ class SocialPostGenerator {
1245
1294
  llm;
1246
1295
  model;
1247
1296
  i18n;
1297
+ modelSelector;
1298
+ selectionContext;
1248
1299
  constructor(options) {
1249
1300
  this.llm = options?.llm;
1250
1301
  this.model = options?.model;
1251
1302
  this.i18n = createContentGenI18n(options?.locale);
1303
+ this.modelSelector = options?.modelSelector;
1304
+ this.selectionContext = options?.selectionContext;
1252
1305
  }
1253
1306
  async generate(brief) {
1254
1307
  if (this.llm) {
@@ -1258,9 +1311,22 @@ class SocialPostGenerator {
1258
1311
  }
1259
1312
  return this.generateFallback(brief);
1260
1313
  }
1314
+ async resolveModel() {
1315
+ if (this.model)
1316
+ return this.model;
1317
+ if (this.modelSelector) {
1318
+ const ctx = this.selectionContext ?? {
1319
+ taskDimension: "reasoning"
1320
+ };
1321
+ const result = await this.modelSelector.select(ctx);
1322
+ return result.modelId;
1323
+ }
1324
+ return;
1325
+ }
1261
1326
  async generateWithLlm(brief) {
1262
1327
  if (!this.llm)
1263
1328
  return [];
1329
+ const model = await this.resolveModel();
1264
1330
  const response = await this.llm.chat([
1265
1331
  {
1266
1332
  role: "system",
@@ -1275,7 +1341,7 @@ class SocialPostGenerator {
1275
1341
  role: "user",
1276
1342
  content: [{ type: "text", text: JSON.stringify(brief) }]
1277
1343
  }
1278
- ], { responseFormat: "json", model: this.model });
1344
+ ], { responseFormat: "json", model });
1279
1345
  const part = response.message.content.find((chunk) => ("text" in chunk));
1280
1346
  if (!part || !("text" in part))
1281
1347
  return [];
@@ -922,11 +922,15 @@ class LandingPageGenerator {
922
922
  llm;
923
923
  model;
924
924
  i18n;
925
+ modelSelector;
926
+ selectionContext;
925
927
  constructor(options) {
926
928
  this.options = options;
927
929
  this.llm = options?.llm;
928
930
  this.model = options?.model;
929
931
  this.i18n = createContentGenI18n(options?.locale);
932
+ this.modelSelector = options?.modelSelector;
933
+ this.selectionContext = options?.selectionContext;
930
934
  }
931
935
  async generate(brief) {
932
936
  if (this.llm) {
@@ -934,10 +938,21 @@ class LandingPageGenerator {
934
938
  }
935
939
  return this.generateFallback(brief);
936
940
  }
941
+ async resolveModel() {
942
+ if (this.model)
943
+ return this.model;
944
+ if (this.modelSelector) {
945
+ const ctx = this.selectionContext ?? { taskDimension: "coding" };
946
+ const result = await this.modelSelector.select(ctx);
947
+ return result.modelId;
948
+ }
949
+ return;
950
+ }
937
951
  async generateWithLlm(brief) {
938
952
  if (!this.llm) {
939
953
  return this.generateFallback(brief);
940
954
  }
955
+ const model = await this.resolveModel();
941
956
  const response = await this.llm.chat([
942
957
  {
943
958
  role: "system",
@@ -954,7 +969,7 @@ class LandingPageGenerator {
954
969
  }
955
970
  ], {
956
971
  responseFormat: "json",
957
- model: this.model,
972
+ model,
958
973
  temperature: this.options?.temperature ?? 0.5
959
974
  });
960
975
  const part = response.message.content.find((chunk) => ("text" in chunk));
@@ -921,10 +921,14 @@ class SocialPostGenerator {
921
921
  llm;
922
922
  model;
923
923
  i18n;
924
+ modelSelector;
925
+ selectionContext;
924
926
  constructor(options) {
925
927
  this.llm = options?.llm;
926
928
  this.model = options?.model;
927
929
  this.i18n = createContentGenI18n(options?.locale);
930
+ this.modelSelector = options?.modelSelector;
931
+ this.selectionContext = options?.selectionContext;
928
932
  }
929
933
  async generate(brief) {
930
934
  if (this.llm) {
@@ -934,9 +938,22 @@ class SocialPostGenerator {
934
938
  }
935
939
  return this.generateFallback(brief);
936
940
  }
941
+ async resolveModel() {
942
+ if (this.model)
943
+ return this.model;
944
+ if (this.modelSelector) {
945
+ const ctx = this.selectionContext ?? {
946
+ taskDimension: "reasoning"
947
+ };
948
+ const result = await this.modelSelector.select(ctx);
949
+ return result.modelId;
950
+ }
951
+ return;
952
+ }
937
953
  async generateWithLlm(brief) {
938
954
  if (!this.llm)
939
955
  return [];
956
+ const model = await this.resolveModel();
940
957
  const response = await this.llm.chat([
941
958
  {
942
959
  role: "system",
@@ -951,7 +968,7 @@ class SocialPostGenerator {
951
968
  role: "user",
952
969
  content: [{ type: "text", text: JSON.stringify(brief) }]
953
970
  }
954
- ], { responseFormat: "json", model: this.model });
971
+ ], { responseFormat: "json", model });
955
972
  const part = response.message.content.find((chunk) => ("text" in chunk));
956
973
  if (!part || !("text" in part))
957
974
  return [];
@@ -922,11 +922,15 @@ class BlogGenerator {
922
922
  model;
923
923
  temperature;
924
924
  i18n;
925
+ modelSelector;
926
+ selectionContext;
925
927
  constructor(options) {
926
928
  this.llm = options?.llm;
927
929
  this.model = options?.model;
928
930
  this.temperature = options?.temperature ?? 0.4;
929
931
  this.i18n = createContentGenI18n(options?.locale);
932
+ this.modelSelector = options?.modelSelector;
933
+ this.selectionContext = options?.selectionContext;
930
934
  }
931
935
  async generate(brief) {
932
936
  if (this.llm) {
@@ -934,10 +938,23 @@ class BlogGenerator {
934
938
  }
935
939
  return this.generateDeterministic(brief);
936
940
  }
941
+ async resolveModel() {
942
+ if (this.model)
943
+ return this.model;
944
+ if (this.modelSelector) {
945
+ const ctx = this.selectionContext ?? {
946
+ taskDimension: "reasoning"
947
+ };
948
+ const result = await this.modelSelector.select(ctx);
949
+ return result.modelId;
950
+ }
951
+ return;
952
+ }
937
953
  async generateWithLlm(brief) {
938
954
  if (!this.llm) {
939
955
  return this.generateDeterministic(brief);
940
956
  }
957
+ const model = await this.resolveModel();
941
958
  const response = await this.llm.chat([
942
959
  {
943
960
  role: "system",
@@ -959,7 +976,7 @@ class BlogGenerator {
959
976
  }
960
977
  ], {
961
978
  responseFormat: "json",
962
- model: this.model,
979
+ model,
963
980
  temperature: this.temperature
964
981
  });
965
982
  const jsonPart = response.message.content.find((part) => ("text" in part));
@@ -1021,11 +1038,15 @@ class EmailCampaignGenerator {
1021
1038
  model;
1022
1039
  temperature;
1023
1040
  i18n;
1041
+ modelSelector;
1042
+ selectionContext;
1024
1043
  constructor(options) {
1025
1044
  this.llm = options?.llm;
1026
1045
  this.model = options?.model;
1027
1046
  this.temperature = options?.temperature ?? 0.6;
1028
1047
  this.i18n = createContentGenI18n(options?.locale);
1048
+ this.modelSelector = options?.modelSelector;
1049
+ this.selectionContext = options?.selectionContext;
1029
1050
  }
1030
1051
  async generate(input) {
1031
1052
  if (this.llm) {
@@ -1035,9 +1056,22 @@ class EmailCampaignGenerator {
1035
1056
  }
1036
1057
  return this.generateFallback(input);
1037
1058
  }
1059
+ async resolveModel() {
1060
+ if (this.model)
1061
+ return this.model;
1062
+ if (this.modelSelector) {
1063
+ const ctx = this.selectionContext ?? {
1064
+ taskDimension: "reasoning"
1065
+ };
1066
+ const result = await this.modelSelector.select(ctx);
1067
+ return result.modelId;
1068
+ }
1069
+ return;
1070
+ }
1038
1071
  async generateWithLlm(input) {
1039
1072
  if (!this.llm)
1040
1073
  return null;
1074
+ const model = await this.resolveModel();
1041
1075
  const response = await this.llm.chat([
1042
1076
  {
1043
1077
  role: "system",
@@ -1054,7 +1088,7 @@ class EmailCampaignGenerator {
1054
1088
  }
1055
1089
  ], {
1056
1090
  responseFormat: "json",
1057
- model: this.model,
1091
+ model,
1058
1092
  temperature: this.temperature
1059
1093
  });
1060
1094
  const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
@@ -1150,11 +1184,15 @@ class LandingPageGenerator {
1150
1184
  llm;
1151
1185
  model;
1152
1186
  i18n;
1187
+ modelSelector;
1188
+ selectionContext;
1153
1189
  constructor(options) {
1154
1190
  this.options = options;
1155
1191
  this.llm = options?.llm;
1156
1192
  this.model = options?.model;
1157
1193
  this.i18n = createContentGenI18n(options?.locale);
1194
+ this.modelSelector = options?.modelSelector;
1195
+ this.selectionContext = options?.selectionContext;
1158
1196
  }
1159
1197
  async generate(brief) {
1160
1198
  if (this.llm) {
@@ -1162,10 +1200,21 @@ class LandingPageGenerator {
1162
1200
  }
1163
1201
  return this.generateFallback(brief);
1164
1202
  }
1203
+ async resolveModel() {
1204
+ if (this.model)
1205
+ return this.model;
1206
+ if (this.modelSelector) {
1207
+ const ctx = this.selectionContext ?? { taskDimension: "coding" };
1208
+ const result = await this.modelSelector.select(ctx);
1209
+ return result.modelId;
1210
+ }
1211
+ return;
1212
+ }
1165
1213
  async generateWithLlm(brief) {
1166
1214
  if (!this.llm) {
1167
1215
  return this.generateFallback(brief);
1168
1216
  }
1217
+ const model = await this.resolveModel();
1169
1218
  const response = await this.llm.chat([
1170
1219
  {
1171
1220
  role: "system",
@@ -1182,7 +1231,7 @@ class LandingPageGenerator {
1182
1231
  }
1183
1232
  ], {
1184
1233
  responseFormat: "json",
1185
- model: this.model,
1234
+ model,
1186
1235
  temperature: this.options?.temperature ?? 0.5
1187
1236
  });
1188
1237
  const part = response.message.content.find((chunk) => ("text" in chunk));
@@ -1245,10 +1294,14 @@ class SocialPostGenerator {
1245
1294
  llm;
1246
1295
  model;
1247
1296
  i18n;
1297
+ modelSelector;
1298
+ selectionContext;
1248
1299
  constructor(options) {
1249
1300
  this.llm = options?.llm;
1250
1301
  this.model = options?.model;
1251
1302
  this.i18n = createContentGenI18n(options?.locale);
1303
+ this.modelSelector = options?.modelSelector;
1304
+ this.selectionContext = options?.selectionContext;
1252
1305
  }
1253
1306
  async generate(brief) {
1254
1307
  if (this.llm) {
@@ -1258,9 +1311,22 @@ class SocialPostGenerator {
1258
1311
  }
1259
1312
  return this.generateFallback(brief);
1260
1313
  }
1314
+ async resolveModel() {
1315
+ if (this.model)
1316
+ return this.model;
1317
+ if (this.modelSelector) {
1318
+ const ctx = this.selectionContext ?? {
1319
+ taskDimension: "reasoning"
1320
+ };
1321
+ const result = await this.modelSelector.select(ctx);
1322
+ return result.modelId;
1323
+ }
1324
+ return;
1325
+ }
1261
1326
  async generateWithLlm(brief) {
1262
1327
  if (!this.llm)
1263
1328
  return [];
1329
+ const model = await this.resolveModel();
1264
1330
  const response = await this.llm.chat([
1265
1331
  {
1266
1332
  role: "system",
@@ -1275,7 +1341,7 @@ class SocialPostGenerator {
1275
1341
  role: "user",
1276
1342
  content: [{ type: "text", text: JSON.stringify(brief) }]
1277
1343
  }
1278
- ], { responseFormat: "json", model: this.model });
1344
+ ], { responseFormat: "json", model });
1279
1345
  const part = response.message.content.find((chunk) => ("text" in chunk));
1280
1346
  if (!part || !("text" in part))
1281
1347
  return [];
@@ -4,8 +4,11 @@ export declare class BlogGenerator {
4
4
  private readonly model?;
5
5
  private readonly temperature;
6
6
  private readonly i18n;
7
+ private readonly modelSelector?;
8
+ private readonly selectionContext?;
7
9
  constructor(options?: GeneratorOptions);
8
10
  generate(brief: ContentBrief): Promise<GeneratedContent>;
11
+ private resolveModel;
9
12
  private generateWithLlm;
10
13
  private generateDeterministic;
11
14
  private renderWhyNow;
@@ -923,11 +923,15 @@ class BlogGenerator {
923
923
  model;
924
924
  temperature;
925
925
  i18n;
926
+ modelSelector;
927
+ selectionContext;
926
928
  constructor(options) {
927
929
  this.llm = options?.llm;
928
930
  this.model = options?.model;
929
931
  this.temperature = options?.temperature ?? 0.4;
930
932
  this.i18n = createContentGenI18n(options?.locale);
933
+ this.modelSelector = options?.modelSelector;
934
+ this.selectionContext = options?.selectionContext;
931
935
  }
932
936
  async generate(brief) {
933
937
  if (this.llm) {
@@ -935,10 +939,23 @@ class BlogGenerator {
935
939
  }
936
940
  return this.generateDeterministic(brief);
937
941
  }
942
+ async resolveModel() {
943
+ if (this.model)
944
+ return this.model;
945
+ if (this.modelSelector) {
946
+ const ctx = this.selectionContext ?? {
947
+ taskDimension: "reasoning"
948
+ };
949
+ const result = await this.modelSelector.select(ctx);
950
+ return result.modelId;
951
+ }
952
+ return;
953
+ }
938
954
  async generateWithLlm(brief) {
939
955
  if (!this.llm) {
940
956
  return this.generateDeterministic(brief);
941
957
  }
958
+ const model = await this.resolveModel();
942
959
  const response = await this.llm.chat([
943
960
  {
944
961
  role: "system",
@@ -960,7 +977,7 @@ class BlogGenerator {
960
977
  }
961
978
  ], {
962
979
  responseFormat: "json",
963
- model: this.model,
980
+ model,
964
981
  temperature: this.temperature
965
982
  });
966
983
  const jsonPart = response.message.content.find((part) => ("text" in part));
@@ -4,8 +4,11 @@ export declare class EmailCampaignGenerator {
4
4
  private readonly model?;
5
5
  private readonly temperature;
6
6
  private readonly i18n;
7
+ private readonly modelSelector?;
8
+ private readonly selectionContext?;
7
9
  constructor(options?: GeneratorOptions);
8
10
  generate(input: EmailCampaignBrief): Promise<EmailDraft>;
11
+ private resolveModel;
9
12
  private generateWithLlm;
10
13
  private generateFallback;
11
14
  private subjects;
@@ -923,11 +923,15 @@ class EmailCampaignGenerator {
923
923
  model;
924
924
  temperature;
925
925
  i18n;
926
+ modelSelector;
927
+ selectionContext;
926
928
  constructor(options) {
927
929
  this.llm = options?.llm;
928
930
  this.model = options?.model;
929
931
  this.temperature = options?.temperature ?? 0.6;
930
932
  this.i18n = createContentGenI18n(options?.locale);
933
+ this.modelSelector = options?.modelSelector;
934
+ this.selectionContext = options?.selectionContext;
931
935
  }
932
936
  async generate(input) {
933
937
  if (this.llm) {
@@ -937,9 +941,22 @@ class EmailCampaignGenerator {
937
941
  }
938
942
  return this.generateFallback(input);
939
943
  }
944
+ async resolveModel() {
945
+ if (this.model)
946
+ return this.model;
947
+ if (this.modelSelector) {
948
+ const ctx = this.selectionContext ?? {
949
+ taskDimension: "reasoning"
950
+ };
951
+ const result = await this.modelSelector.select(ctx);
952
+ return result.modelId;
953
+ }
954
+ return;
955
+ }
940
956
  async generateWithLlm(input) {
941
957
  if (!this.llm)
942
958
  return null;
959
+ const model = await this.resolveModel();
943
960
  const response = await this.llm.chat([
944
961
  {
945
962
  role: "system",
@@ -956,7 +973,7 @@ class EmailCampaignGenerator {
956
973
  }
957
974
  ], {
958
975
  responseFormat: "json",
959
- model: this.model,
976
+ model,
960
977
  temperature: this.temperature
961
978
  });
962
979
  const jsonPart = response.message.content.find((chunk) => ("text" in chunk));