@futdevpro/nts-dynamo 1.11.15 → 1.11.17

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.
Files changed (37) hide show
  1. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +1 -1
  2. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -1
  3. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +31 -13
  4. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -1
  5. package/build/_modules/discord-assistant/_services/dias-io.control-service.js +6 -2
  6. package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -1
  7. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts +1 -1
  8. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts.map +1 -1
  9. package/build/_modules/discord-bot/_models/dibo-global-settings.interface.d.ts +88 -0
  10. package/build/_modules/discord-bot/_models/dibo-global-settings.interface.d.ts.map +1 -0
  11. package/build/_modules/discord-bot/_models/dibo-global-settings.interface.js +3 -0
  12. package/build/_modules/discord-bot/_models/dibo-global-settings.interface.js.map +1 -0
  13. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +0 -1
  14. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts.map +1 -1
  15. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +0 -3
  16. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js.map +1 -1
  17. package/build/_modules/discord-bot/index.d.ts +1 -1
  18. package/build/_modules/discord-bot/index.d.ts.map +1 -1
  19. package/build/_modules/discord-bot/index.js +1 -1
  20. package/build/_modules/discord-bot/index.js.map +1 -1
  21. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +284 -58
  22. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -1
  23. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js +91 -104
  24. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -1
  25. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts +246 -53
  26. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -1
  27. package/build/_modules/open-ai/_services/oai-llm.service-base.js +86 -96
  28. package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -1
  29. package/package.json +3 -3
  30. package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +26 -25
  31. package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +6 -6
  32. package/src/_modules/discord-bot/_collections/dibo-global-settings.conts.ts +1 -1
  33. package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +2 -2
  34. package/src/_modules/discord-bot/index.ts +1 -1
  35. package/src/_modules/open-ai/_services/oai-llm-chat.service-base.ts +233 -249
  36. package/src/_modules/open-ai/_services/oai-llm.service-base.ts +189 -147
  37. /package/src/_modules/discord-bot/_models/{global-bot-log-settings.interface.ts → dibo-global-settings.interface.ts} +0 -0
@@ -1,4 +1,3 @@
1
- /* import { DyFM_safeParseList } from '@futdevpro/fsm-dynamo'; */
2
1
  import { OpenAI } from 'openai';
3
2
 
4
3
  import { DyFM_OpenAI_Settings, DyFM_OpenAIModel, DyFM_GPTCall_Settings } from '@futdevpro/fsm-dynamo/open-ai';
@@ -81,16 +80,18 @@ export class DyNTS_OAI_LLM_ServiceBase {
81
80
  * and the {@link DyNTS_OAI_LLM_Predefined_Requests.yesNo.upperCaseYes} to check the answer
82
81
  */
83
82
  async askYesNoQuestion(
84
- question: string,
85
- issuer: string,
86
- settings?: DyFM_GPTCall_Settings,
87
- debugLog?: boolean,
88
- /** this is used to readably replace too long contents to eg '...' in logs */
89
- replaceThisInLog?: string
83
+ set: {
84
+ question: string,
85
+ issuer: string,
86
+ settings?: DyFM_GPTCall_Settings,
87
+ debugLog?: boolean,
88
+ /** this is used to readably replace too long contents to eg '...' in logs */
89
+ replaceThisInLog?: string
90
+ }
90
91
  ): Promise<boolean> {
91
- question += this.predefinedRequests.yesNo.request;
92
+ set.question += this.predefinedRequests.yesNo.request;
92
93
 
93
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
94
+ const answer = await this.askQuestion(set);
94
95
 
95
96
  return answer.toUpperCase().includes(this.predefinedRequests.yesNo.upperCaseYes);
96
97
  }
@@ -103,20 +104,22 @@ export class DyNTS_OAI_LLM_ServiceBase {
103
104
  * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.percentageOnly} to ask the question
104
105
  */
105
106
  async askPercentageQuestion(
106
- question: string,
107
- issuer: string,
108
- settings?: DyFM_GPTCall_Settings,
109
- debugLog?: boolean,
110
- /** this is used to readably replace too long contents to eg '...' in logs */
111
- replaceThisInLog?: string
107
+ set: {
108
+ question: string,
109
+ issuer: string,
110
+ settings?: DyFM_GPTCall_Settings,
111
+ debugLog?: boolean,
112
+ /** this is used to readably replace too long contents to eg '...' in logs */
113
+ replaceThisInLog?: string,
114
+ }
112
115
  ): Promise<number> {
113
- question += this.predefinedRequests.percentageOnly;
116
+ set.question += this.predefinedRequests.percentageOnly;
114
117
 
115
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
118
+ const answer = await this.askQuestion(set);
116
119
 
117
120
  if (isNaN(+answer)) {
118
121
  DyFM_Log.error('GPT_ServiceBase', 'asykPercentageQuestion', 'Invalid answer', {
119
- question,
122
+ question: set.question,
120
123
  answer,
121
124
  });
122
125
 
@@ -134,26 +137,28 @@ export class DyNTS_OAI_LLM_ServiceBase {
134
137
  * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
135
138
  */
136
139
  async askSelectQuestion(
137
- question: string,
138
- selectFrom: string[],
139
- issuer: string,
140
- settings?: DyFM_GPTCall_Settings,
141
- debugLog?: boolean,
142
- /** this is used to readably replace too long contents to eg '...' in logs */
143
- replaceThisInLog?: string
140
+ set: {
141
+ question: string,
142
+ selectFrom: string[],
143
+ issuer: string,
144
+ settings?: DyFM_GPTCall_Settings,
145
+ debugLog?: boolean,
146
+ /** this is used to readably replace too long contents to eg '...' in logs */
147
+ replaceThisInLog?: string,
148
+ }
144
149
  ): Promise<string> {
145
150
  // replace the {{DyNTS_selectOptions}} with the list of options
146
151
  const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
147
152
  '{{DyNTS_selectOptions}}',
148
- this.getTextListAsText(selectFrom)
153
+ this.getTextListAsText(set.selectFrom)
149
154
  );
150
- question += selectQuestionAddition;
155
+ set.question += selectQuestionAddition;
151
156
 
152
- let answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
157
+ let answer = await this.askQuestion(set);
153
158
 
154
159
  answer = answer.toLocaleUpperCase();
155
160
 
156
- for (const item of selectFrom) {
161
+ for (const item of set.selectFrom) {
157
162
  if (answer.includes(item.toLocaleUpperCase())) return item;
158
163
  }
159
164
 
@@ -170,21 +175,23 @@ export class DyNTS_OAI_LLM_ServiceBase {
170
175
  * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
171
176
  */
172
177
  async requestSelect<T>(
173
- question: string,
174
- selectFrom: T[],
175
- issuer: string,
176
- settings?: DyFM_GPTCall_Settings,
177
- debugLog?: boolean,
178
- /** this is used to readably replace too long contents to eg '...' in logs */
179
- replaceThisInLog?: string,
178
+ set: {
179
+ question: string,
180
+ selectFrom: T[],
181
+ issuer: string,
182
+ settings?: DyFM_GPTCall_Settings,
183
+ debugLog?: boolean,
184
+ /** this is used to readably replace too long contents to eg '...' in logs */
185
+ replaceThisInLog?: string,
186
+ }
180
187
  ): Promise<T | { unparsableResult: string }> {
181
188
  const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
182
189
  '{{DyNTS_selectOptions}}',
183
- this.getTextListAsText(selectFrom.map(item => `"${JSON.stringify(item)}"`))
190
+ this.getTextListAsText(set.selectFrom.map(item => `"${JSON.stringify(item)}"`))
184
191
  );
185
- question += selectQuestionAddition;
192
+ set.question += selectQuestionAddition;
186
193
 
187
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
194
+ const answer = await this.askQuestion(set);
188
195
 
189
196
  return DyFM_safeParseJSON<T>(answer);
190
197
  }
@@ -197,27 +204,29 @@ export class DyNTS_OAI_LLM_ServiceBase {
197
204
  * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
198
205
  */
199
206
  async askMultipleSelectQuestionWithOptions(
200
- question: string,
201
- options: string[],
202
- issuer: string,
203
- settings?: DyFM_GPTCall_Settings,
204
- debugLog?: boolean,
205
- /** this is used to readably replace too long contents to eg '...' in logs */
206
- replaceThisInLog?: string
207
+ set: {
208
+ question: string,
209
+ options: string[],
210
+ issuer: string,
211
+ settings?: DyFM_GPTCall_Settings,
212
+ debugLog?: boolean,
213
+ /** this is used to readably replace too long contents to eg '...' in logs */
214
+ replaceThisInLog?: string,
215
+ }
207
216
  ): Promise<string[]> {
208
217
  const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
209
218
  '{{DyNTS_selectOptions}}',
210
- this.getTextListAsText(options)
219
+ this.getTextListAsText(set.options)
211
220
  );
212
- question += selectQuestionAddition;
221
+ set.question += selectQuestionAddition;
213
222
 
214
- let answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
223
+ let answer = await this.askQuestion(set);
215
224
 
216
225
  answer = answer.toLocaleUpperCase();
217
226
 
218
227
  const result: string[] = [];
219
228
 
220
- for (const item of options) {
229
+ for (const item of set.options) {
221
230
  if (answer.includes(item.toLocaleUpperCase())) {
222
231
  result.push(item);
223
232
  }
@@ -236,21 +245,23 @@ export class DyNTS_OAI_LLM_ServiceBase {
236
245
  * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
237
246
  */
238
247
  async requestMultipleSelect<T>(
239
- question: string,
240
- options: T[],
241
- issuer: string,
242
- settings?: DyFM_GPTCall_Settings,
243
- debugLog?: boolean,
244
- /** this is used to readably replace too long contents to eg '...' in logs */
245
- replaceThisInLog?: string,
248
+ set: {
249
+ question: string,
250
+ options: T[],
251
+ issuer: string,
252
+ settings?: DyFM_GPTCall_Settings,
253
+ debugLog?: boolean,
254
+ /** this is used to readably replace too long contents to eg '...' in logs */
255
+ replaceThisInLog?: string,
256
+ }
246
257
  ): Promise<T[]> {
247
258
  const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
248
259
  '{{DyNTS_selectOptions}}',
249
- this.getTextListAsText(options.map(item => `"${JSON.stringify(item)}"`))
260
+ this.getTextListAsText(set.options.map(item => `"${JSON.stringify(item)}"`))
250
261
  );
251
- question += selectQuestionAddition;
262
+ set.question += selectQuestionAddition;
252
263
 
253
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
264
+ const answer = await this.askQuestion(set);
254
265
 
255
266
  return DyFM_safeParseList<T[]>(answer);
256
267
  }
@@ -267,16 +278,18 @@ export class DyNTS_OAI_LLM_ServiceBase {
267
278
  * (uses {@link DyFM_safeParseJSON})
268
279
  */
269
280
  async askJSONQuestion<T = any>(
270
- question: string,
271
- issuer: string,
272
- settings?: DyFM_GPTCall_Settings,
273
- debugLog?: boolean,
274
- /** this is used to readably replace too long contents to eg '...' in logs */
275
- replaceThisInLog?: string
281
+ set: {
282
+ question: string,
283
+ issuer: string,
284
+ settings?: DyFM_GPTCall_Settings,
285
+ debugLog?: boolean,
286
+ /** this is used to readably replace too long contents to eg '...' in logs */
287
+ replaceThisInLog?: string,
288
+ }
276
289
  ): Promise<T | { unparsableResult: string }> {
277
- question += this.predefinedRequests.jsonRequest;
290
+ set.question += this.predefinedRequests.jsonRequest;
278
291
 
279
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
292
+ const answer = await this.askQuestion(set);
280
293
 
281
294
  return DyFM_safeParseJSON<T>(answer);
282
295
  }
@@ -293,21 +306,23 @@ export class DyNTS_OAI_LLM_ServiceBase {
293
306
  * (uses {@link DyFM_safeParseJSON})
294
307
  */
295
308
  async askJSONQuestionWithKeysDescription<T = any>(
296
- question: string,
297
- keysDescription: string,
298
- issuer: string,
299
- settings?: DyFM_GPTCall_Settings,
300
- debugLog?: boolean,
301
- /** this is used to readably replace too long contents to eg '...' in logs */
302
- replaceThisInLog?: string
309
+ set: {
310
+ question: string,
311
+ keysDescription: string,
312
+ issuer: string,
313
+ settings?: DyFM_GPTCall_Settings,
314
+ debugLog?: boolean,
315
+ /** this is used to readably replace too long contents to eg '...' in logs */
316
+ replaceThisInLog?: string,
317
+ }
303
318
  ): Promise<T | { unparsableResult: string }> {
304
319
  const jsonRequestWithKeysDescription = this.predefinedRequests.jsonRequestWithKeysDescription.replace(
305
320
  '{{DyNTS_jsonKeysDescription}}',
306
- keysDescription
321
+ set.keysDescription
307
322
  );
308
- question += jsonRequestWithKeysDescription;
323
+ set.question += jsonRequestWithKeysDescription;
309
324
 
310
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
325
+ const answer = await this.askQuestion(set);
311
326
 
312
327
  return DyFM_safeParseJSON<T>(answer);
313
328
  }
@@ -324,21 +339,23 @@ export class DyNTS_OAI_LLM_ServiceBase {
324
339
  * (uses {@link DyFM_safeParseJSON})
325
340
  */
326
341
  async askJSONQuestionWithExactKeys<T = any>(
327
- question: string,
328
- keys: string[],
329
- issuer: string,
330
- settings?: DyFM_GPTCall_Settings,
331
- debugLog?: boolean,
332
- /** this is used to readably replace too long contents to eg '...' in logs */
333
- replaceThisInLog?: string
342
+ set: {
343
+ question: string,
344
+ keys: string[],
345
+ issuer: string,
346
+ settings?: DyFM_GPTCall_Settings,
347
+ debugLog?: boolean,
348
+ /** this is used to readably replace too long contents to eg '...' in logs */
349
+ replaceThisInLog?: string,
350
+ }
334
351
  ): Promise<T | { unparsableResult: string }> {
335
352
  const jsonRequestWithExactKeys = this.predefinedRequests.jsonRequestWithExactKeys.replace(
336
353
  '{{DyNTS_jsonKeys}}',
337
- this.getTextListAsText(keys)
354
+ this.getTextListAsText(set.keys)
338
355
  );
339
- question += jsonRequestWithExactKeys;
356
+ set.question += jsonRequestWithExactKeys;
340
357
 
341
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
358
+ const answer = await this.askQuestion(set);
342
359
 
343
360
  return DyFM_safeParseJSON<T>(answer);
344
361
  }
@@ -355,16 +372,18 @@ export class DyNTS_OAI_LLM_ServiceBase {
355
372
  * (uses {@link DyFM_safeParseList})
356
373
  */
357
374
  async askListQuestion(
358
- question: string,
359
- issuer: string,
360
- settings?: DyFM_GPTCall_Settings,
361
- debugLog?: boolean,
362
- /** this is used to readably replace too long contents to eg '...' in logs */
363
- replaceThisInLog?: string,
375
+ set: {
376
+ question: string,
377
+ issuer: string,
378
+ settings?: DyFM_GPTCall_Settings,
379
+ debugLog?: boolean,
380
+ /** this is used to readably replace too long contents to eg '...' in logs */
381
+ replaceThisInLog?: string,
382
+ }
364
383
  ): Promise<string[]> {
365
- question += this.predefinedRequests.listRequest;
384
+ set.question += this.predefinedRequests.listRequest;
366
385
 
367
- const answer = await this.askQuestion(question, issuer, settings, debugLog, replaceThisInLog);
386
+ const answer = await this.askQuestion(set);
368
387
 
369
388
  return DyFM_safeParseList(answer);
370
389
  }
@@ -379,16 +398,22 @@ export class DyNTS_OAI_LLM_ServiceBase {
379
398
  * Uses the {@link resolveSimpleUserMessage}
380
399
  */
381
400
  async askQuestion(
382
- question: string,
383
- issuer: string,
384
- settings?: DyFM_GPTCall_Settings,
385
- debugLog?: boolean,
386
- /** this is used to readably replace too long contents to eg '...' in logs */
387
- replaceThisInLog?: string,
401
+ set: {
402
+ question: string,
403
+ issuer: string,
404
+ settings?: DyFM_GPTCall_Settings,
405
+ debugLog?: boolean,
406
+ /** this is used to readably replace too long contents to eg '...' in logs */
407
+ replaceThisInLog?: string,
408
+ }
388
409
  ): Promise<string> {
389
- this.logQuestion(question, replaceThisInLog, debugLog);
410
+ this.logQuestion(set);
390
411
 
391
- const answer = await this.resolveSimpleUserMessage(question, issuer, settings);
412
+ const answer = await this.resolveSimpleUserMessage({
413
+ message: set.question,
414
+ issuer: set.issuer,
415
+ settings: set.settings,
416
+ });
392
417
 
393
418
  if (this.debugLog) {
394
419
  console.log(' - ', answer);
@@ -426,16 +451,18 @@ export class DyNTS_OAI_LLM_ServiceBase {
426
451
  * Uses the {@link resolveMessage}
427
452
  */
428
453
  async resolveSimpleUserMessage(
429
- message: string,
430
- issuer: string,
431
- settings?: DyFM_GPTCall_Settings
454
+ set: {
455
+ message: string,
456
+ issuer: string,
457
+ settings?: DyFM_GPTCall_Settings
458
+ }
432
459
  ): Promise<string> {
433
- return this.resolveMessage(
434
- [{ role: DyNTS_OAI_GPT_Message_Role.user, content: message }],
435
- issuer,
436
- settings,
437
- false
438
- ) as Promise<string>;
460
+ return this.resolveMessage({
461
+ conversation: [{ role: DyNTS_OAI_GPT_Message_Role.user, content: set.message }],
462
+ issuer: set.issuer,
463
+ settings: set.settings,
464
+ getFullResponse: false,
465
+ }) as Promise<string>;
439
466
  }
440
467
  /** the exact same as {@link resolveSimpleUserMessage} */
441
468
  simpleUserMessage = this.resolveSimpleUserMessage;
@@ -448,26 +475,28 @@ export class DyNTS_OAI_LLM_ServiceBase {
448
475
  * Uses the {@link getMessageCreateInput}
449
476
  */
450
477
  async resolveMessage(
451
- conversation: DyNTS_OAI_GPT_Message[],
452
- issuer: string,
453
- settings?: DyFM_GPTCall_Settings,
454
- getFullResponse?: boolean
478
+ set: {
479
+ conversation: DyNTS_OAI_GPT_Message[],
480
+ issuer: string,
481
+ settings?: DyFM_GPTCall_Settings,
482
+ getFullResponse?: boolean
483
+ }
455
484
  ): Promise<string | ChatCompletion> {
456
485
  try {
457
- conversation.unshift(this.getDefaultSystemMessage(settings));
486
+ set.conversation.unshift(this.getDefaultSystemMessage(set.settings));
458
487
 
459
488
  const result: ChatCompletion = await this.openai.chat.completions.create(
460
- this.getMessageCreateInput(conversation, issuer, settings)
489
+ this.getMessageCreateInput(set)
461
490
  ) as ChatCompletion;
462
491
 
463
- if (getFullResponse) {
492
+ if (set.getFullResponse) {
464
493
  return result;
465
494
  }
466
495
 
467
496
  return result.choices[0].message.content;
468
497
  } catch (error) {
469
498
  throw new DyFM_Error({
470
- ...this.getDefaultErrorSettings('resolveConversation', error, issuer),
499
+ ...this.getDefaultErrorSettings('resolveConversation', error, set.issuer),
471
500
 
472
501
  errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-OAB-RC0`,
473
502
  });
@@ -479,13 +508,19 @@ export class DyNTS_OAI_LLM_ServiceBase {
479
508
  /**
480
509
  * Logs the question if the debugLog is true
481
510
  */
482
- protected logQuestion(question: string, replaceThisInLog?: string, debugLog?: boolean): void {
483
- if (debugLog ?? this.debugLog) {
484
- if (replaceThisInLog) {
485
- question = question.replace(replaceThisInLog, this.defaultLogReplacer);
511
+ protected logQuestion(
512
+ set: {
513
+ question: string,
514
+ replaceThisInLog?: string,
515
+ debugLog?: boolean
516
+ }
517
+ ): void {
518
+ if (set.debugLog ?? this.debugLog) {
519
+ if (set.replaceThisInLog) {
520
+ set.question = set.question.replace(set.replaceThisInLog, this.defaultLogReplacer);
486
521
  }
487
522
 
488
- console.log('\n - ', question);
523
+ console.log('\n - ', set.question);
489
524
  }
490
525
  }
491
526
 
@@ -509,40 +544,47 @@ export class DyNTS_OAI_LLM_ServiceBase {
509
544
  * Uses the {@link getDefaultSystemMessage}
510
545
  */
511
546
  protected getMessageCreateInput(
512
- messages: DyNTS_OAI_GPT_Message[],
513
- issuer: string,
514
- settings: DyFM_GPTCall_Settings = this.defaultSettings
547
+ set: {
548
+ conversation: DyNTS_OAI_GPT_Message[],
549
+ issuer: string,
550
+ settings?: DyFM_GPTCall_Settings
551
+ }
515
552
  ): ChatCompletionCreateParamsBase {
516
553
  try {
554
+ const settings = set.settings ?? this.defaultSettings;
555
+
517
556
  const result: ChatCompletionCreateParamsBase = {
518
- model: settings.useModel ?? this.defaultModel,
519
- messages: messages as ChatCompletionMessageParam[],
557
+ model: settings?.useModel ?? this.defaultModel,
558
+ messages: set.conversation as ChatCompletionMessageParam[],
520
559
  };
521
560
 
522
- if (DyFM_notNull(settings.temperature)) {
523
- result.temperature = settings.temperature;
524
- }
561
+ result.temperature = DyFM_notNull(settings?.temperature) ?
562
+ settings.temperature :
563
+ this.defaultSettings.temperature;
525
564
 
526
- if (DyFM_notNull(settings.maxTokens)) {
527
- result.max_tokens = settings.maxTokens;
528
- }
565
+ /* result.max_tokens = DyFM_notNull(settings?.maxTokens) ?
566
+ settings.maxTokens :
567
+ this.defaultSettings.maxTokens; */
568
+ result.max_completion_tokens = DyFM_notNull(settings?.maxTokens) ?
569
+ settings.maxTokens :
570
+ this.defaultSettings.maxTokens;
529
571
 
530
- if (DyFM_notNull(settings.topP)) {
531
- result.top_p = settings.topP;
532
- }
572
+ result.top_p = DyFM_notNull(settings?.topP) ?
573
+ settings.topP :
574
+ this.defaultSettings.topP;
533
575
 
534
- if (DyFM_notNull(settings.frequencyPenalty)) {
535
- result.frequency_penalty = settings.frequencyPenalty;
536
- }
576
+ result.frequency_penalty = DyFM_notNull(settings?.frequencyPenalty) ?
577
+ settings.frequencyPenalty :
578
+ this.defaultSettings.frequencyPenalty;
537
579
 
538
- if (DyFM_notNull(settings.presencePenalty)) {
539
- result.presence_penalty = settings.presencePenalty;
540
- }
580
+ result.presence_penalty = DyFM_notNull(settings?.presencePenalty) ?
581
+ settings.presencePenalty :
582
+ this.defaultSettings.presencePenalty;
541
583
 
542
584
  return result;
543
585
  } catch (error) {
544
586
  throw new DyFM_Error({
545
- ...this.getDefaultErrorSettings('getMessageCreateSettings', error, issuer),
587
+ ...this.getDefaultErrorSettings('getMessageCreateSettings', error, set.issuer),
546
588
 
547
589
  errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-OAB-RC0`,
548
590
  });