MCPcopy Create free account
hub / github.com/github/gh-aw / splitContentIntoChunks

Function splitContentIntoChunks

pkg/workflow/compiler_yaml.go:432–461  ·  view source on GitHub ↗
(content string)

Source from the content-addressed store, hash-verified

430}
431
432func splitContentIntoChunks(content string) []string {
433 const maxChunkSize = 20900 // 21000 - 100 character buffer
434 const indentSpaces = " " // 10 spaces added to each line
435
436 lines := strings.Split(content, "\n")
437 var chunks []string
438 var currentChunk []string
439 currentSize := 0
440
441 for _, line := range lines {
442 lineSize := len(indentSpaces) + len(line) + 1 // +1 for newline
443
444 // If adding this line would exceed the limit, start a new chunk
445 if currentSize+lineSize > maxChunkSize && len(currentChunk) > 0 {
446 chunks = append(chunks, strings.Join(currentChunk, "\n"))
447 currentChunk = []string{line}
448 currentSize = lineSize
449 } else {
450 currentChunk = append(currentChunk, line)
451 currentSize += lineSize
452 }
453 }
454
455 // Add the last chunk if there's content
456 if len(currentChunk) > 0 {
457 chunks = append(chunks, strings.Join(currentChunk, "\n"))
458 }
459
460 return chunks
461}
462
463func (c *Compiler) generatePrompt(yaml *strings.Builder, data *WorkflowData, preActivationJobCreated bool, beforeActivationJobs []string) {
464 compilerYamlLog.Printf("Generating prompt for workflow: %s (markdown size: %d bytes)", data.Name, len(data.MarkdownContent))

Callers 3

generatePromptMethod · 0.85

Calls

no outgoing calls

Tested by 1