Public/Get-OAIGPTFileContent.ps1

Function Get-OAIGPTFileContent {
    <#
        .SYNOPSIS
        Retrieves GPT file content from the OpenAI Compliance API.
 
        .DESCRIPTION
        Retrieves the content of a file associated with a GPT from the ChatGPT Enterprise compliance API.
 
        .PARAMETER FileId
        The ID of the GPT file to retrieve.
 
        .INPUTS
        System.String
         
        .OUTPUTS
        System.Object
 
        .EXAMPLE
        Get-OAIGPTFileContent -FileId "file-123456789"
 
    #>

    [CmdletBinding()]
    [OutputType([System.Object])]
    param(
        [Parameter(Mandatory=$true, Position=0)]
        [string]$FileId
    
    )
    Begin {
        Write-Debug "Validating OpenAI Compliance client initialization"
        If (!$script:client) {
            Write-Error "OpenAI Compliance client not initialized. Please run Initialize-OAICompliance first." -ErrorAction Stop
            
        }
        Write-Debug "Creating OAI GPT manager"
        $gpt_manager = [OAIGPT]::new($script:client)

    } Process {
        Write-Debug "Retrieving GPT file content for FileId: $fileId"
        Try {
            $response = $gpt_manager.GetGPTFileContent($fileId)
            Write-Debug "Response retrieved successfully"
                
        } Catch {
            Write-Error "Error retrieving GPT file content: $($_.Exception.Message)" -ErrorAction Stop
        
        }
    } End {
        Write-Debug "Successfully retrieved GPT file content"
        $response
    
    }
}