mirror of
https://github.com/danielmiessler/fabric.git
synced 2026-09-10 07:36:44 -04:00
Merge pull request #1828 from ksylvan/kayvan/fix-empty-input-bug
Fix empty string detection in chatter and AI clients
This commit is contained in:
commit
14c95d7bc1
6
cmd/generate_changelog/incoming/1828.txt
Normal file
6
cmd/generate_changelog/incoming/1828.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
### PR [#1828](https://github.com/danielmiessler/Fabric/pull/1828) by [ksylvan](https://github.com/ksylvan): Fix empty string detection in chatter and AI clients
|
||||
|
||||
- Chore: improve message handling by trimming whitespace in content checks
|
||||
- Remove default space in `BuildSession` message content
|
||||
- Trim whitespace in `anthropic` message content check
|
||||
- Trim whitespace in `gemini` message content check
|
||||
|
|
@ -175,7 +175,7 @@ func (o *Chatter) BuildSession(request *domain.ChatRequest, raw bool) (session *
|
|||
if request.Message == nil {
|
||||
request.Message = &chat.ChatCompletionMessage{
|
||||
Role: chat.ChatMessageRoleUser,
|
||||
Content: " ",
|
||||
Content: "",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ func (an *Client) toMessages(msgs []*chat.ChatCompletionMessage) (ret []anthropi
|
|||
lastRoleWasUser := false
|
||||
|
||||
for _, msg := range msgs {
|
||||
if msg.Content == "" {
|
||||
if strings.TrimSpace(msg.Content) == "" {
|
||||
continue // Skip empty messages
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ func (o *Client) convertMessages(msgs []*chat.ChatCompletionMessage) []*genai.Co
|
|||
content.Role = "user"
|
||||
}
|
||||
|
||||
if msg.Content != "" {
|
||||
if strings.TrimSpace(msg.Content) != "" {
|
||||
content.Parts = append(content.Parts, &genai.Part{Text: msg.Content})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue