Skip to content

Commit

Permalink
Merge pull request #386 from nerdalert/escape-hyphens
Browse files Browse the repository at this point in the history
Escape hypens in seed questions
  • Loading branch information
vishnoianil authored Jun 17, 2024
2 parents faf11da + 6686f01 commit c603f76
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions worker/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -415,6 +416,10 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {

context, hasContext := example["context"].(string)
originalQuestion := question

// Escape sequences of two or more hyphens in the question to avoid ilab seeing a flag request
question = escapeHyphens(question)

// Slicing args breaks ilab chat for context, use Sprintf to control spacing
if hasContext {
// Append the context to the question with a specific format
Expand Down Expand Up @@ -1222,6 +1227,14 @@ func (w *Worker) handleOutputFiles(outputDir, prNumber, outDirName string) strin
return indexUpKey
}

// escapeHyphens escapes sequences of two or more hyphens in the input string.
func escapeHyphens(input string) string {
re := regexp.MustCompile(`-{2,}`)
return re.ReplaceAllStringFunc(input, func(match string) string {
return strings.Repeat(`\-`, len(match))
})
}

/* Uncomment to bypass ilab diff (temporary until upstream files are validated prior to merge)
// discoverGitTaxonomyFiles discovers new or modified YAML taxonomy files in the specified Git repository.
// This temporarily replaces ilab diff since that fails on most files because it's hard to validate when most taxonomies
Expand Down

0 comments on commit c603f76

Please sign in to comment.