Skip to content

Commit ebd97eb

Browse files
authored
Merge pull request #115 from dfinke/fix-message-fields
Fix message fields
2 parents f15e1c8 + 958b3d3 commit ebd97eb

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

PSAI.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
RootModule = 'PSAI.psm1'
3-
ModuleVersion = '0.5.2'
3+
ModuleVersion = '0.5.3'
44
GUID = '68662d19-a8f1-484f-b1b7-3bf0e8a436df'
55
Author = 'Douglas Finke'
66
CompanyName = 'Doug Finke'

Public/ConvertTo-OAIMessage.ps1

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,33 @@ function ConvertTo-OAIMessage {
2323
)
2424

2525
Process {
26-
$Message | ConvertTo-Json -Depth 5 | ConvertFrom-Json -AsHashtable -Depth 5
26+
$converted = $Message | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashtable -Depth 10
27+
28+
foreach ($key in @('refusal', 'annotations')) {
29+
if ($converted.ContainsKey($key)) {
30+
$converted.Remove($key)
31+
}
32+
}
33+
34+
if ($converted.ContainsKey('content') -and $converted['content'] -is [array]) {
35+
foreach ($part in $converted['content']) {
36+
if ($part -is [hashtable]) {
37+
foreach ($k in @('refusal', 'annotations')) {
38+
if ($part.ContainsKey($k)) {
39+
$part.Remove($k)
40+
}
41+
}
42+
if ($part.ContainsKey('text') -and $part['text'] -is [hashtable]) {
43+
foreach ($k in @('refusal', 'annotations')) {
44+
if ($part['text'].ContainsKey($k)) {
45+
$part['text'].Remove($k)
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
53+
$converted
2754
}
2855
}

Public/New-Agent.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ function New-Agent {
211211
LLM = $LLM
212212
}
213213

214-
$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")
214+
$script:messages += @(
215+
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."
216+
)
215217

216218
if ($Instructions) {
217219
# $agent['Instructions'] = $Instructions

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.5.3
2+
3+
- Fixed assistant messages to not include `refusal` or `annotations` properties when converting for API input
4+
- Updated system prompt in New-Agent to keep responses concise and pattern-aligned without domain-specific rules
5+
- Simplified ConvertTo-OAIMessage function for better maintainability
6+
17
## v0.5.2
28

39
- Added `/rewind` slash command to InteractiveCLI for rewinding the conversation to before the last user message

0 commit comments

Comments
 (0)