It's not a bad idea, but the last value has very little chance of appearing

FOR I=1:1:100 {W $Piece("SAD,MED,TEN,BOB,RAN",",",$r(4)+1),"-" }

TEN-TEN-BOB-TEN-SAD-MED-MED-MED-MED-MED-TEN-MED-BOB-MED-MED-TEN-TEN-MED-SAD-BOB-MED-SAD-BOB-
TEN-TEN-BOB-BOB-SAD-BOB-TEN-MED-BOB-BOB-MED-TEN-MED-SAD-BOB-BOB-BOB-MED-MED-TEN-MED-TEN-MED-
TEN-BOB-MED-TEN-SAD-MED-MED-MED-BOB-SAD-SAD-MED-SAD-BOB-SAD-TEN-BOB-BOB-TEN-BOB-TEN-BOB-SAD-
SAD-TEN-MED-TEN-SAD-BOB-MED-SAD-SAD-BOB-MED-TEN-TEN-SAD-SAD-SAD-BOB-BOB-BOB-TEN-MED-BOB-BOB-
TEN-BOB-SAD-SAD-BOB-BOB-BOB-MED

SAD    20%
MED    27%
TEN    23%
BOB    30%
RAN    0%

I've tried to user other way, for example, using a GUID, get the checksum and get the module 5

Something like $Piece("SAD,MED,TEN,BOB,RAN",",",($ZCRC(##class(%SYSTEM.Util).CreateGUID(),0)#5) + 1)

for i=1:1:100 {W $Piece("SAD,MED,TEN,BOB,RAN",",",($ZCRC(##class(%SYSTEM.Util).CreateGUID(),0)#5) + 1),"-"}

TEN-SAD-BOB-MED-BOB-BOB-MED-MED-BOB-RAN-MED-BOB-RAN-MED-RAN-BOB-BOB-MED-RAN-SAD-RAN-MED-MED-
BOB-TEN-BOB-RAN-MED-TEN-TEN-TEN-SAD-BOB-MED-BOB-BOB-BOB-RAN-RAN-TEN-MED-RAN-RAN-BOB-RAN-TEN-
MED-TEN-TEN-MED-RAN-BOB-TEN-SAD-SAD-TEN-TEN-TEN-BOB-RAN-MED-SAD-MED-SAD-RAN-RAN-RAN-BOB-MED-
SAD-MED-RAN-RAN-SAD-RAN-RAN-BOB-MED-TEN-TEN-RAN-BOB-TEN-TEN-RAN-BOB-BOB-TEN-MED-SAD-SAD-BOB-
BOB-BOB-SAD-TEN-MED-TEN-BOB-SAD

SAD    13%
MED    20%
TEN    20%
BOB    25%
RAN    22%

I have best percentage to get a different value.

Thanks for you answer.

We have solved the problem of the delay in BP, and now, the number of new instances of BS has been drastically reduced.

We are talking with the customer to upgrade the actor pool number to create a 3 new instances of the BP. The customer is worried that this increase in instances could affect memory performance, because more instances created, more memory it requires.

Hi,

In iris.script add the following line:

zpm "install iris-deploy-tools -v" 

In TgGptProduction.cls remove the settings of Token and ApiKey

<Item Name="Telegram.InboundService" Category="" ClassName="Telegram.LongPollingService" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Adapter" Name="SSLConfig">tg</Setting>
    <Setting Target="Host" Name="Target">GPTRouter</Setting>
</Item>
....
<Item Name="St.OpenAi.BO.Api.Connect" Category="" ClassName="St.OpenAi.BO.Api.Connect" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="Organization"></Setting>
    <Setting Target="Adapter" Name="SSLConfig">tg</Setting>
</Item>

In Setup.cls, extends the class to St.Tools.Deploy and modify the loop to add the default configuration.

Class shvarov.telegramgpt.Setup Extends St.Tools.Deploy
{
ClassMethod Init(TgToken As %String, GPTKey As %String) As %Status
{
    set st=$$$OK
    set production="shvarov.telegramgpt.i14y.TgGptProduction"
    for item="Telegram.InboundService","Telegram.OutboundOperation" {
        set st = ..AddDefaultSetting("*",item,,"Token",TgToken)
        quit:$$$ISERR(st)
    }
    set item="St.OpenAi.BO.Api.Connect"
    set st = ..AddDefaultSetting("*",item,,"ApiKey",GPTKey)
    return st
}
....
}

I hope you find it useful