Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hyphens from the context. ilab consider it as a possible input… #420

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions worker/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,12 @@ func (w *Worker) runKnowledgePrecheck(lab string, labDiffOutput []string, modelN
w.logger.Error("Invalid seed example format in knowledge YAML file")
continue
}
context, ok := example["context"].(string)
originalContext, ok := example["context"].(string)
if !ok {
w.logger.Error("Context not found or not a string in seed example of knowledge")
continue
}

originalContext := context

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

qnaPairs, hasQnAPairs := example["questions_and_answers"].([]interface{})

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

// Escape sequences of two or more hyphens in the question to avoid ilab seeing a flag request
originalQuestion := question
question = escapeHyphens(question)
// Append the context to the question with a specific format
question := escapeHyphens(originalQuestion)

// In case of knowledge, it doesn't make sense to provide the context with the question
// Commenting out the context appending in case we need to revert back
// question = fmt.Sprintf("%s %s %s.", question, ctxPrompt, context)
Expand Down Expand Up @@ -636,7 +630,7 @@ func (w *Worker) runSkillPrecheck(lab string, labDiffOutput []string, modelName
w.logger.Error("Invalid seed example format in the skill")
continue
}
question, ok := example["question"].(string)
originalQuestion, ok := example["question"].(string)
if !ok {
w.logger.Error("Question not found or not a string in the skill")
continue
Expand All @@ -647,14 +641,14 @@ func (w *Worker) runSkillPrecheck(lab string, labDiffOutput []string, modelName
continue
}

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

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

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

if hasContext {
logData["context"] = context
logData["context"] = originalContext
}

logYAML, err := yaml.Marshal(logData)
Expand Down
Loading