MCPcopy
hub / github.com/ConnectAI-E/feishu-openai / SetMsg

Method SetMsg

code/services/sessionCache.go:143–161  ·  view source on GitHub ↗
(sessionId string, msg []openai.Messages)

Source from the content-addressed store, hash-verified

141}
142
143func (s *SessionService) SetMsg(sessionId string, msg []openai.Messages) {
144 maxLength := 4096
145 maxCacheTime := time.Hour * 12
146
147 //限制对话上下文长度
148 for getStrPoolTotalLength(msg) > maxLength {
149 msg = append(msg[:1], msg[2:]...)
150 }
151
152 sessionContext, ok := s.cache.Get(sessionId)
153 if !ok {
154 sessionMeta := &SessionMeta{Msg: msg}
155 s.cache.Set(sessionId, sessionMeta, maxCacheTime)
156 return
157 }
158 sessionMeta := sessionContext.(*SessionMeta)
159 sessionMeta.Msg = msg
160 s.cache.Set(sessionId, sessionMeta, maxCacheTime)
161}
162
163func (s *SessionService) SetPicStyle(sessionId string, style PicStyle) {
164 maxCacheTime := time.Hour * 12

Callers

nothing calls this directly

Calls 3

getStrPoolTotalLengthFunction · 0.85
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected