mkht / PSOpenAI

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

Remove-VectorStoreFile Piping Expectation #12

Closed potatoqualitee closed 6 months ago

potatoqualitee commented 7 months ago

Seems like this should work?

Get-VectorStoreFile -All -InputObject vs_B60tYk3Fm9LuylRAJ29TkNro | Where-Object status -eq failed | Remove-VectorStoreFile
Remove-VectorStoreFile : Cannot validate argument on parameter 'InputObject'. The "
[bool](Get-VectorStoreIdFromInputObject $_) " validation script for the argument with
value "@{id=file-A0rMDqSXee8kgY5gg171gxuN; object=vector_store.file; usage_bytes=0;
vector_store_id=vs_B60tYk3Fm9LuylRAJ29TkNro; status=failed; last_error=;
created_at=5/2/2024 8:53:16 PM}" did not return a result of True. Determine why the     validation script failed, and then try the command again.                               At line:1 char:102                                                                      + ... lRAJ29TkNro | Where-Object status -eq failed | Remove-VectorStoreFile      
potatoqualitee commented 7 months ago

This as well

Start-VectorStoreFileBatch -VectorStore $vs -FileId $uploadedfiles2.id | Wait-VectorStoreFileBatch
Wait-VectorStoreFileBatch : Cannot validate argument on parameter 'InputObject'. The "
[bool](Get-VectorStoreIdFromInputObject $_) " validation script for the argument with
value "@{id=vsfb_53d4c9c984bc4056a60c54a0804b0988; object=vector_store.file_batch;
status=in_progress; vector_store_id=vs_B60tYk3Fm9LuylRAJ29TkNro; file_counts=;
created_at=5/2/2024 9:25:41 PM}" did not return a result of True. Determine why the
validation script failed, and then try the command again.
At line:1 char:74
+ ... ectorStore $vs -FileId $uploadedfiles2.id | Wait-VectorStoreFileBatch
mkht commented 7 months ago

I wish it would work too, but it doesn't, at least not right now, due to limitations in PowerShell's pipeline system. I'll see if I can find a better workaround.

mkht commented 6 months ago

In PR #14, the parameters of Assistants related commands have been significantly overhauled. This makes the following pipeline to work.

Get-VectorStoreFile -VectorStoreId 'vs_abc123' -All | Where-Object status -eq failed | Remove-VectorStoreFile

# This is a bit of an extreme example.
Get-VectorStore 'vs_abc123' | `
    Start-VectorStoreFileBatch -FileId $UploadedFiles | `
       Wait-VectorStoreFileBatch | `
            Get-VectorStoreFileInBatch -Filter failed | `
                Remove-VectorStoreFile

However, there are some side effects. Previously, the -InputObject parameter could accept both an object and an ID string, but the new version requires the use of a separate parameter for each.


$vso = Get-VectorStore 'vs_abc123'

# Working
Remove-VectorStore -InputObject $vso
Remove-VectorStore -VectorStore $vso
Remove-VectorStore -VectorStoreId "vs_abc123"
Remove-VectorStore $vso
Remove-VectorStore "vs_abc123"
$vso | Remove-VectorStore
"vs_abc123" | Remove-VectorStore

# Not working
Remove-VectorStore -InputObject "vs_abc123"