Documentation
¶
Overview ¶
Package testutil provides mock DeepSeek helpers for N07 cache E2E tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LongestCommonPrefix ¶
LongestCommonPrefix returns the length of the shared prefix of two strings.
Types ¶
type MockChatRequest ¶
type MockChatRequest struct {
Messages []struct {
Role string `json:"role"`
Content any `json:"content"`
} `json:"messages"`
}
MockChatRequest carries the prompt fields used by the mock.
type PrefixCacheSimulator ¶
type PrefixCacheSimulator struct {
// contains filtered or unexported fields
}
PrefixCacheSimulator records prompts and estimates hits from their longest common prefix. Stable turns yield high ratios; a preset switch initially misses, then recovers as the new prefix repeats.
func NewDeepSeekMock ¶
func NewDeepSeekMock() (*httptest.Server, *PrefixCacheSimulator)
NewDeepSeekMock creates a mock server whose SSE usage cache fields are derived from PrefixCacheSimulator for each request.
func NewPrefixCacheSimulator ¶
func NewPrefixCacheSimulator() *PrefixCacheSimulator
NewPrefixCacheSimulator creates a simulator.
func (*PrefixCacheSimulator) Simulate ¶
func (s *PrefixCacheSimulator) Simulate(prompt string) (hit, miss int)
Simulate returns hit and miss token counts based on the shared prefix with the previous prompt; no shared prefix means all misses.
type PrefixHash ¶
type PrefixHash struct {
// PromptText contains the assembled prompt.
PromptText string
// Tokens estimates token count as characters divided by four.
Tokens int
}
PrefixHash fingerprints the prompt prefix for cache matching.