mkht / PSOpenAI

PowerShell module for OpenAI API.
MIT License
41 stars 11 forks source link

Infinite loop #21

Closed potatoqualitee closed 5 months ago

potatoqualitee commented 5 months ago

Sometimes when I'm uploading a batch of files to the vector store, it hangs here:

image

I will be showing this command next week at psconf -- would love if it could be fixed by then. ill come back and show you the command once ive made it public, if needed.

mkht commented 5 months ago

It is odd that the loop does not exit even though the status is set to complete.

Could you tell me what command you are running? I'm assuming you are probably using a combination of Start-VectorStoreFileBatch and Wait-VectorStoreFileBatch, is that correct? As a temporary workaround, you might be able to use the -TimeoutSec parameter of Wait-VectorStoreFileBatch to avoid the infinite loop.

potatoqualitee commented 5 months ago

Thanks for the prompt response! Here is the command it's embedded within

https://github.com/potatoqualitee/PSHelp.Copilot/blob/main/public/New-ModuleAssistant.ps1

mkht commented 5 months ago

https://github.com/potatoqualitee/PSHelp.Copilot/blob/e24c0fff5e34c5d26f08a1b0b496e7b879f05aab/public/Initialize-VectorStore.ps1#L123-L125

Perhaps this is where the infinite loop occurs?

You are using the -StatusForWait parameter incorrectly, if you specify "completed" for -StatusForWait, it will wait until the batch status becomes "other than" completed. If you want to wait until completion, specify "completed" for -StatusForExit. Also, it is necessary to prevent an infinite loop in such a case, since the batch status may become "failed" due to some problem.

$null = PSOpenAI\Wait-VectorStoreFileBatch -VectorStore $vectorStore -BatchId $filebatch.id -StatusForExit 'completed', 'failed'

The default if nothing is specified is-StatusforWait "in_progress", which means that the batch will wait while in_progress and will exit the loop when the status becomes other than in_progress.

potatoqualitee commented 5 months ago

Sweet thank you! I'll try that and close this issue if it's resolved.

potatoqualitee commented 5 months ago

cant duplicate 😊