mirror of
https://github.com/coaidev/coai.git
synced 2025-05-28 17:30:15 +09:00
fix: fix claude system prompt (merge pr #152)
This commit is contained in:
commit
12f497a655
@ -72,7 +72,7 @@ func (c *ChatInstance) ConvertMessages(props *adaptercommon.ChatProps) []globals
|
||||
|
||||
// if is system message, set it to user message
|
||||
if message.Role == globals.System {
|
||||
message.Role = globals.User
|
||||
continue
|
||||
}
|
||||
|
||||
// anthropic api does not allow multi-same role messages
|
||||
@ -126,12 +126,22 @@ func (c *ChatInstance) GetMessages(props *adaptercommon.ChatProps) []Message {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ChatInstance) GetSystemPrompt(props *adaptercommon.ChatProps) (prompt string) {
|
||||
for _, message := range props.Message {
|
||||
if message.Role == globals.System {
|
||||
prompt += message.Content
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ChatInstance) GetChatBody(props *adaptercommon.ChatProps, stream bool) *ChatBody {
|
||||
messages := c.GetMessages(props)
|
||||
return &ChatBody{
|
||||
Messages: messages,
|
||||
MaxTokens: c.GetTokens(props),
|
||||
Model: props.Model,
|
||||
System: c.GetSystemPrompt(props),
|
||||
Stream: stream,
|
||||
Temperature: props.Temperature,
|
||||
TopP: props.TopP,
|
||||
|
@ -23,6 +23,7 @@ type ChatBody struct {
|
||||
Messages []Message `json:"messages"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
Model string `json:"model"`
|
||||
System string `json:"system"`
|
||||
Stream bool `json:"stream"`
|
||||
Temperature *float32 `json:"temperature,omitempty"`
|
||||
TopP *float32 `json:"top_p,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user