diff --git a/PSAI.psd1 b/PSAI.psd1 index 13ef293..379dcac 100644 --- a/PSAI.psd1 +++ b/PSAI.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'PSAI.psm1' - ModuleVersion = '0.5.2' + ModuleVersion = '0.5.3' GUID = '68662d19-a8f1-484f-b1b7-3bf0e8a436df' Author = 'Douglas Finke' CompanyName = 'Doug Finke' diff --git a/Public/ConvertTo-OAIMessage.ps1 b/Public/ConvertTo-OAIMessage.ps1 index 631999a..8ac2fc2 100644 --- a/Public/ConvertTo-OAIMessage.ps1 +++ b/Public/ConvertTo-OAIMessage.ps1 @@ -23,6 +23,33 @@ function ConvertTo-OAIMessage { ) Process { - $Message | ConvertTo-Json -Depth 5 | ConvertFrom-Json -AsHashtable -Depth 5 + $converted = $Message | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashtable -Depth 10 + + foreach ($key in @('refusal', 'annotations')) { + if ($converted.ContainsKey($key)) { + $converted.Remove($key) + } + } + + if ($converted.ContainsKey('content') -and $converted['content'] -is [array]) { + foreach ($part in $converted['content']) { + if ($part -is [hashtable]) { + foreach ($k in @('refusal', 'annotations')) { + if ($part.ContainsKey($k)) { + $part.Remove($k) + } + } + if ($part.ContainsKey('text') -and $part['text'] -is [hashtable]) { + foreach ($k in @('refusal', 'annotations')) { + if ($part['text'].ContainsKey($k)) { + $part['text'].Remove($k) + } + } + } + } + } + } + + $converted } } diff --git a/Public/New-Agent.ps1 b/Public/New-Agent.ps1 index f2218eb..b3d242c 100644 --- a/Public/New-Agent.ps1 +++ b/Public/New-Agent.ps1 @@ -211,7 +211,9 @@ function New-Agent { LLM = $LLM } - $script:messages += @(New-ChatRequestSystemMessage "You are a helpful agent. If you are configured with tools, you can use them to assist the user. They are also considered skills") + $script:messages += @( + New-ChatRequestSystemMessage "You are a helpful agent. Answer every request concisely and follow the style established earlier in the conversation. If you are configured with tools, you can use them to assist the user. They are also considered skills." + ) if ($Instructions) { # $agent['Instructions'] = $Instructions diff --git a/changelog.md b/changelog.md index 9ff443c..bd4d15c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## v0.5.3 + +- Fixed assistant messages to not include `refusal` or `annotations` properties when converting for API input +- Updated system prompt in New-Agent to keep responses concise and pattern-aligned without domain-specific rules +- Simplified ConvertTo-OAIMessage function for better maintainability + ## v0.5.2 - Added `/rewind` slash command to InteractiveCLI for rewinding the conversation to before the last user message