MCPcopy Create free account
hub / github.com/astercloud/aster / compactFormat

Method compactFormat

pkg/agent/prompt_optimizer.go:420–431  ·  view source on GitHub ↗

compactFormat 紧凑格式

(prompt string)

Source from the content-addressed store, hash-verified

418
419// compactFormat 紧凑格式
420func (c *EnhancedPromptCompressor) compactFormat(prompt string) string {
421 lines := strings.Split(prompt, "\n")
422 var result []string
423
424 for _, line := range lines {
425 // 保留缩进,但移除行尾空格
426 trimmed := strings.TrimRight(line, " \t")
427 result = append(result, trimmed)
428 }
429
430 return strings.Join(result, "\n")
431}
432
433// EstimateTokens 估算 Token 数
434func (c *EnhancedPromptCompressor) EstimateTokens(ctx context.Context, text string) (int, error) {

Callers 2

compressSimpleMethod · 0.95
TestCompactFormatFunction · 0.95

Calls 1

JoinMethod · 0.45

Tested by 1

TestCompactFormatFunction · 0.76