Skip to content

如果用户提供的函数没有description,就应该明确报错,不让他继续使用 #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions code365scripts.openai/Private/Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @{
Expand Down
3 changes: 1 addition & 2 deletions code365scripts.openai/Public/New-ChatGPTConversation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @{}
}
Expand Down