Skip to content

Commit 05e65a7

Browse files
authored
Merge pull request #420 from vishnoianil/fix-hyphens
Remove hyphens from the context. ilab consider it as a possible input…
2 parents 8467721 + 906202e commit 05e65a7

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

worker/cmd/generate.go

+9-15
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,12 @@ func (w *Worker) runKnowledgePrecheck(lab string, labDiffOutput []string, modelN
482482
w.logger.Error("Invalid seed example format in knowledge YAML file")
483483
continue
484484
}
485-
context, ok := example["context"].(string)
485+
originalContext, ok := example["context"].(string)
486486
if !ok {
487487
w.logger.Error("Context not found or not a string in seed example of knowledge")
488488
continue
489489
}
490490

491-
originalContext := context
492-
493-
// Escape sequences of two or more hyphens in the question to avoid ilab seeing a flag request
494-
// context = escapeHyphens(context)
495-
496491
qnaPairs, hasQnAPairs := example["questions_and_answers"].([]interface{})
497492

498493
if !hasQnAPairs {
@@ -508,7 +503,7 @@ func (w *Worker) runKnowledgePrecheck(lab string, labDiffOutput []string, modelN
508503
w.logger.Errorf("Invalid question and answer format in knowledge seed example %d", seIndex)
509504
continue
510505
}
511-
question, ok := qna["question"].(string)
506+
originalQuestion, ok := qna["question"].(string)
512507
if !ok {
513508
w.logger.Errorf("Question not found or not a string in knowledge seed example %d", seIndex)
514509
continue
@@ -521,9 +516,8 @@ func (w *Worker) runKnowledgePrecheck(lab string, labDiffOutput []string, modelN
521516
}
522517

523518
// Escape sequences of two or more hyphens in the question to avoid ilab seeing a flag request
524-
originalQuestion := question
525-
question = escapeHyphens(question)
526-
// Append the context to the question with a specific format
519+
question := escapeHyphens(originalQuestion)
520+
527521
// In case of knowledge, it doesn't make sense to provide the context with the question
528522
// Commenting out the context appending in case we need to revert back
529523
// question = fmt.Sprintf("%s %s %s.", question, ctxPrompt, context)
@@ -636,7 +630,7 @@ func (w *Worker) runSkillPrecheck(lab string, labDiffOutput []string, modelName
636630
w.logger.Error("Invalid seed example format in the skill")
637631
continue
638632
}
639-
question, ok := example["question"].(string)
633+
originalQuestion, ok := example["question"].(string)
640634
if !ok {
641635
w.logger.Error("Question not found or not a string in the skill")
642636
continue
@@ -647,14 +641,14 @@ func (w *Worker) runSkillPrecheck(lab string, labDiffOutput []string, modelName
647641
continue
648642
}
649643

650-
context, hasContext := example["context"].(string)
651-
originalQuestion := question
644+
originalContext, hasContext := example["context"].(string)
652645

653646
// Escape sequences of two or more hyphens in the question to avoid ilab seeing a flag request
654-
question = escapeHyphens(question)
647+
question := escapeHyphens(originalQuestion)
655648

656649
// Slicing args breaks ilab chat for context, use Sprintf to control spacing
657650
if hasContext {
651+
context := escapeHyphens(originalContext)
658652
// Append the context to the question with a specific format
659653
question = fmt.Sprintf("%s %s %s.", question, ctxPrompt, context)
660654
}
@@ -694,7 +688,7 @@ func (w *Worker) runSkillPrecheck(lab string, labDiffOutput []string, modelName
694688
}
695689

696690
if hasContext {
697-
logData["context"] = context
691+
logData["context"] = originalContext
698692
}
699693

700694
logYAML, err := yaml.Marshal(logData)

0 commit comments

Comments
 (0)