summaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-02-06 12:42:06 +0300
committerGrail Finder <wohilas@gmail.com>2026-02-06 12:42:06 +0300
commit4af866079c3f21eab12b02c3158567539ca40c50 (patch)
treed428557aae121ba89e66c728240723a9c4e718ec /models
parent478a505869bf26b15dcbc77feb2c09c1f2ff4aac (diff)
Chore: linter complaints
Diffstat (limited to 'models')
-rw-r--r--models/db.go2
-rw-r--r--models/models.go32
-rw-r--r--models/openrouter.go3
3 files changed, 20 insertions, 17 deletions
diff --git a/models/db.go b/models/db.go
index 090f46d..73a0b53 100644
--- a/models/db.go
+++ b/models/db.go
@@ -14,7 +14,7 @@ type Chat struct {
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
-func (c Chat) ToHistory() ([]RoleMsg, error) {
+func (c *Chat) ToHistory() ([]RoleMsg, error) {
resp := []RoleMsg{}
if err := json.Unmarshal([]byte(c.Msgs), &resp); err != nil {
return nil, err
diff --git a/models/models.go b/models/models.go
index 4133a7c..34e3dcf 100644
--- a/models/models.go
+++ b/models/models.go
@@ -98,7 +98,7 @@ type RoleMsg struct {
}
// MarshalJSON implements custom JSON marshaling for RoleMsg
-func (m RoleMsg) MarshalJSON() ([]byte, error) {
+func (m *RoleMsg) MarshalJSON() ([]byte, error) {
if m.hasContentParts {
// Use structured content format
aux := struct {
@@ -166,11 +166,11 @@ func (m *RoleMsg) UnmarshalJSON(data []byte) error {
return nil
}
-func (m RoleMsg) ToText(i int) string {
+func (m *RoleMsg) ToText(i int) string {
icon := fmt.Sprintf("(%d)", i)
// Convert content to string representation
- contentStr := ""
+ var contentStr string
if !m.hasContentParts {
contentStr = m.Content
} else {
@@ -198,8 +198,8 @@ func (m RoleMsg) ToText(i int) string {
return strings.ReplaceAll(textMsg, "\n\n", "\n")
}
-func (m RoleMsg) ToPrompt() string {
- contentStr := ""
+func (m *RoleMsg) ToPrompt() string {
+ var contentStr string
if !m.hasContentParts {
contentStr = m.Content
} else {
@@ -240,7 +240,7 @@ func NewMultimodalMsg(role string, contentParts []interface{}) RoleMsg {
}
// HasContent returns true if the message has either string content or structured content parts
-func (m RoleMsg) HasContent() bool {
+func (m *RoleMsg) HasContent() bool {
if m.Content != "" {
return true
}
@@ -251,17 +251,17 @@ func (m RoleMsg) HasContent() bool {
}
// IsContentParts returns true if the message uses structured content parts
-func (m RoleMsg) IsContentParts() bool {
+func (m *RoleMsg) IsContentParts() bool {
return m.hasContentParts
}
// GetContentParts returns the content parts of the message
-func (m RoleMsg) GetContentParts() []interface{} {
+func (m *RoleMsg) GetContentParts() []interface{} {
return m.ContentParts
}
// Copy creates a copy of the RoleMsg with all fields
-func (m RoleMsg) Copy() RoleMsg {
+func (m *RoleMsg) Copy() RoleMsg {
return RoleMsg{
Role: m.Role,
Content: m.Content,
@@ -382,12 +382,14 @@ func (cb *ChatBody) MakeStopSliceExcluding(
continue
}
// Add multiple variations to catch different formatting
- ss = append(ss, role+":\n") // Most common: role with newline
- ss = append(ss, role+":") // Role with colon but no newline
- ss = append(ss, role+": ") // Role with colon and single space
- ss = append(ss, role+": ") // Role with colon and double space (common tokenization)
- ss = append(ss, role+": \n") // Role with colon and double space (common tokenization)
- ss = append(ss, role+": ") // Role with colon and triple space
+ ss = append(ss,
+ role+":\n", // Most common: role with newline
+ role+":", // Role with colon but no newline
+ role+": ", // Role with colon and single space
+ role+": ", // Role with colon and double space (common tokenization)
+ role+": \n", // Role with colon and double space (common tokenization)
+ role+": ", // Role with colon and triple space
+ )
}
return ss
}
diff --git a/models/openrouter.go b/models/openrouter.go
index 29ba0d8..6196498 100644
--- a/models/openrouter.go
+++ b/models/openrouter.go
@@ -143,7 +143,8 @@ type ORModels struct {
func (orm *ORModels) ListModels(free bool) []string {
resp := []string{}
- for _, model := range orm.Data {
+ for i := range orm.Data {
+ model := &orm.Data[i] // Take address of element to avoid copying
if free {
if model.Pricing.Prompt == "0" && model.Pricing.Completion == "0" {
// treat missing request as free