diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-11-24 12:00:46 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-11-24 12:00:46 +0300 |
| commit | 8a62e987894dc6b0b083d23acfcfad9547fa1106 (patch) | |
| tree | 91f2b3b866874815c162a5333e77e0b6f73f82a4 /llm.go | |
| parent | 504af1a2132ca51f50ab24cd95f2690a4d45323e (diff) | |
Fix: apilinks rotation
Diffstat (limited to 'llm.go')
| -rw-r--r-- | llm.go | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -205,7 +205,6 @@ func (op OpenAIer) FormMsg(msg, role string, resume bool) (io.Reader, error) { newMsg = models.NewRoleMsg(role, msg) } chatBody.Messages = append(chatBody.Messages, newMsg) - // if rag - add as system message to avoid conflicts with tool usage if cfg.RAGEnabled { ragResp, err := chatRagUse(newMsg.Content) @@ -485,7 +484,28 @@ func (or OpenRouterChat) FormMsg(msg, role string, resume bool) (io.Reader, erro chatBody.Messages = append(chatBody.Messages, models.RoleMsg{Role: cfg.ToolRole, Content: toolSysMsg}) } if msg != "" { // otherwise let the bot continue - newMsg := models.RoleMsg{Role: role, Content: msg} + var newMsg models.RoleMsg + // Check if we have an image to add to this message + if imageAttachmentPath != "" { + // Create a multimodal message with both text and image + newMsg = models.NewMultimodalMsg(role, []interface{}{}) + // Add the text content + newMsg.AddTextPart(msg) + // Add the image content + imageURL, err := models.CreateImageURLFromPath(imageAttachmentPath) + if err != nil { + logger.Error("failed to create image URL from path", "error", err, "path", imageAttachmentPath) + // If image processing fails, fall back to simple text message + newMsg = models.NewRoleMsg(role, msg) + imageAttachmentPath = "" // Clear the attachment + } else { + newMsg.AddImagePart(imageURL) + imageAttachmentPath = "" // Clear the attachment after use + } + } else { + // Create a simple text message + newMsg = models.NewRoleMsg(role, msg) + } chatBody.Messages = append(chatBody.Messages, newMsg) // if rag - add as system message to avoid conflicts with tool usage if cfg.RAGEnabled { |
