(chatId string)
| 50 | } |
| 51 | |
| 52 | func (cs *ChatStore) CountUserMessages(chatId string) int { |
| 53 | cs.lock.Lock() |
| 54 | defer cs.lock.Unlock() |
| 55 | |
| 56 | chat := cs.chats[chatId] |
| 57 | if chat == nil { |
| 58 | return 0 |
| 59 | } |
| 60 | |
| 61 | count := 0 |
| 62 | for _, msg := range chat.NativeMessages { |
| 63 | if msg.GetRole() == "user" { |
| 64 | count++ |
| 65 | } |
| 66 | } |
| 67 | return count |
| 68 | } |
| 69 | |
| 70 | func (cs *ChatStore) PostMessage(chatId string, aiOpts *uctypes.AIOptsType, message uctypes.GenAIMessage) error { |
| 71 | cs.lock.Lock() |