From 462a9f2d2203459ae5828f8814efcb2d50cfe4b3 Mon Sep 17 00:00:00 2001 From: chenxizhang Date: Sun, 1 Sep 2024 20:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=94=A8=E6=88=B7=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E7=9A=84=E5=87=BD=E6=95=B0=E6=B2=A1=E6=9C=89descripti?= =?UTF-8?q?on=EF=BC=8C=E5=B0=B1=E5=BA=94=E8=AF=A5=E6=98=8E=E7=A1=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=8C=E4=B8=8D=E8=AE=A9=E4=BB=96=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E4=BD=BF=E7=94=A8=20Fixes=20#271?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code365scripts.openai/Private/Functions.ps1 | 13 +++++++++++++ .../Public/New-ChatGPTConversation.ps1 | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) 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 = @{} }