MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / ComputeCacheKeyForChatCompletionRequest

Function ComputeCacheKeyForChatCompletionRequest

internal/route/util.go:21–38  ·  view source on GitHub ↗
(path string, req *goopenai.ChatCompletionRequest)

Source from the content-addressed store, hash-verified

19}
20
21func ComputeCacheKeyForChatCompletionRequest(path string, req *goopenai.ChatCompletionRequest) string {
22 if req == nil {
23 return ""
24 }
25
26 input := ""
27 for _, m := range req.Messages {
28 input += m.Name
29 input += m.Role
30 input += m.Content
31 }
32
33 if req.ResponseFormat != nil && len(req.ResponseFormat.Type) != 0 {
34 return hasher.Hash(fmt.Sprintf("%s-%s-%s-%s", path, input, req.User, string(req.ResponseFormat.Type)))
35 }
36
37 return hasher.Hash(fmt.Sprintf("%s-%s-%s", path, input, req.User))
38}

Callers 1

getMiddlewareFunction · 0.92

Calls 1

HashFunction · 0.92

Tested by

no test coverage detected