mkht / PSOpenAI

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

Get-OpenAIFileContent errors out #23

Closed potatoqualitee closed 4 months ago

potatoqualitee commented 4 months ago

Please let me know if I'm misusing it.

[48ms] C:/github❯ Get-TuneFile | Select -First 1

object         : file
id             : file-mD4OaP7VpxC08j5SwVGwbOQZ
purpose        : assistants
filename       : Write-PSULog.txt
bytes          : 524
status         : processed
status_details :
created_at     : 6/21/2024 12:09:06 AM

[760ms] C:/github❯ Get-TuneFile | Select -First 1 | Get-TuneFileContent
Invoke-OpenAIAPIRequest: C:\Users\ctrlb\Documents\PowerShell\Modules\PSOpenAI\3.15.1\Public\Files\Get-OpenAIFileContent.ps1:90
Line |
  90 |          $Response = Invoke-OpenAIAPIRequest @params
     |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | OpenAI API returned an 404 (Not Found) Error: Invalid URL (GET
     | /v1/files/@{object=file;+id=file-mD4OaP7VpxC08j5SwVGwbOQZ;+purpose=assistants;+filename=Write-PSULog.txt;+bytes=524;+status=processed;+status_details=;+created_at=06/21/2024+00:09:06}/content)

Calling code looks like this

    [CmdletBinding()]
    param (
        [Parameter(Mandatory, ValueFromPipeline)]
        [Alias("FileId", "file_id")]
        [string[]]$Id
    )
    process {
        foreach ($fileId in $Id) {
            Get-OpenAIFileContent -FileId $fileId
        }
    }
potatoqualitee commented 4 months ago

lol my fault, needed to ValueFromPipelineByPropertyName