mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
fix claude system message
This commit is contained in:
parent
12f497a655
commit
1b161f9264
@ -60,6 +60,12 @@ func (c *ChatInstance) ConvertMessages(props *adaptercommon.ChatProps) []globals
|
|||||||
result := make([]globals.Message, 0)
|
result := make([]globals.Message, 0)
|
||||||
|
|
||||||
for _, message := range props.Message {
|
for _, message := range props.Message {
|
||||||
|
|
||||||
|
// System message is set when constructing Chatbody
|
||||||
|
if message.Role == globals.System {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// if is first message, set it to user message
|
// if is first message, set it to user message
|
||||||
if !start {
|
if !start {
|
||||||
start = true
|
start = true
|
||||||
@ -70,11 +76,6 @@ func (c *ChatInstance) ConvertMessages(props *adaptercommon.ChatProps) []globals
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// if is system message, set it to user message
|
|
||||||
if message.Role == globals.System {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// anthropic api does not allow multi-same role messages
|
// anthropic api does not allow multi-same role messages
|
||||||
if len(result) > 0 && result[len(result)-1].Role == message.Role {
|
if len(result) > 0 && result[len(result)-1].Role == message.Role {
|
||||||
result[len(result)-1].Content += "\n" + message.Content
|
result[len(result)-1].Content += "\n" + message.Content
|
||||||
|
Loading…
Reference in New Issue
Block a user