MCPcopy Create free account
hub / github.com/53AI/53AIHub / buildQueryEmbeddingCacheKey

Function buildQueryEmbeddingCacheKey

api/service/rag/query_embedding_cache.go:72–84  ·  view source on GitHub ↗
(eid int64, query string, channelID int64, modelName string)

Source from the content-addressed store, hash-verified

70const queryEmbeddingCacheTTL = 24 * time.Hour
71
72func buildQueryEmbeddingCacheKey(eid int64, query string, channelID int64, modelName string) string {
73 if eid <= 0 || channelID <= 0 || modelName == "" {
74 return ""
75 }
76 queryHash := sha256.Sum256([]byte(query))
77 modelHash := sha256.Sum256([]byte(modelName))
78 return fmt.Sprintf("Cache:rag:query_embedding:eid:%d:ch:%d:m:%s:q:%s",
79 eid,
80 channelID,
81 hex.EncodeToString(modelHash[:]),
82 hex.EncodeToString(queryHash[:]),
83 )
84}
85
86func (s *EmbeddingService) getCachedQueryEmbedding(cacheKey string) ([]float64, bool) {
87 if cacheKey == "" || !common.IsRedisEnabled() {

Callers 2

GetQueryEmbeddingMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected