diff --git a/code365scripts.openai/Private/Functions.ps1 b/code365scripts.openai/Private/Functions.ps1 index 1cce388..38d980c 100644 --- a/code365scripts.openai/Private/Functions.ps1 +++ b/code365scripts.openai/Private/Functions.ps1 @@ -17,6 +17,19 @@ function Get-FunctionJson { # generate a json object based on the help content of the function $help = Get-Help $functionName + + # if the help doesn't include description, return null + if (-not $help.description) { + Write-Warning "Function $functionName does not have a description." + return $null + } + + # if any parameters don't include description, return null + if ($help.parameters.parameter | Where-Object { -not $_.description }) { + Write-Warning "Function $functionName has parameters without description." + return $null + } + $json = [pscustomobject]@{ type = "function" function = @{ diff --git a/code365scripts.openai/Public/New-ChatGPTConversation.ps1 b/code365scripts.openai/Public/New-ChatGPTConversation.ps1 index 03ef7b7..0587b74 100644 --- a/code365scripts.openai/Public/New-ChatGPTConversation.ps1 +++ b/code365scripts.openai/Public/New-ChatGPTConversation.ps1 @@ -296,9 +296,8 @@ function New-ChatGPTConversation { if ($functions) { $tools = @(Get-PredefinedFunctions -names $functions) - Write-Verbose ($tools | ConvertTo-Json -Depth 10) - if ($tools.Count -gt 0) { + Write-Verbose ($tools | ConvertTo-Json -Depth 10) if ($null -eq $config) { $config = @{} }