- Allowing additional_positive_answer and additional_positive_answer in KOQuestions asset & selection specialist interaction.

This commit is contained in:
Josako
2025-10-03 11:50:59 +02:00
parent 5f387dcef8
commit aeee22b305
2 changed files with 17 additions and 2 deletions

View File

@@ -7,7 +7,9 @@ class KOQuestion(BaseModel):
title: str = Field(..., description="The title of the knockout criterium.") title: str = Field(..., description="The title of the knockout criterium.")
question: str = Field(..., description="The corresponding question asked to the candidate.") question: str = Field(..., description="The corresponding question asked to the candidate.")
answer_positive: Optional[str] = Field(None, description="The answer to the question, resulting in a positive outcome.") answer_positive: Optional[str] = Field(None, description="The answer to the question, resulting in a positive outcome.")
additional_answer_positive: Optional[str] = Field(None, description="2nd answer to the question, resulting in a positive outcome.")
answer_negative: Optional[str] = Field(None, description="The answer to the question, resulting in a negative outcome.") answer_negative: Optional[str] = Field(None, description="The answer to the question, resulting in a negative outcome.")
additional_answer_negative: Optional[str] = Field(None, description="2nd answer to the question, resulting in a negative outcome.")
@classmethod @classmethod
def from_json(cls, json_str: str) -> 'KOQuestion': def from_json(cls, json_str: str) -> 'KOQuestion':

View File

@@ -388,8 +388,11 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
# Evaluate KO Criteria # Evaluate KO Criteria
evaluation = "positive" evaluation = "positive"
criterium, answer = next(iter(self.arguments.form_values.items())) criterium, answer = next(iter(self.arguments.form_values.items()))
if TranslationServices.translate(self.tenant_id, previous_ko_question.answer_positive, self.arguments.language) != answer: if TranslationServices.translate(self.tenant_id, previous_ko_question.answer_negative, self.arguments.language) == answer:
evaluation = "negative" evaluation = "negative"
if previous_ko_question.additional_answer_negative:
if TranslationServices.translate(self.tenant_id, previous_ko_question.additional_answer_negative, self.arguments.language) == answer:
evaluation = "negative"
score = SelectionKOCriteriumScore( score = SelectionKOCriteriumScore(
criterium=criterium, criterium=criterium,
@@ -616,13 +619,23 @@ class SpecialistExecutor(CrewAIBaseSpecialistExecutor):
-> Dict[str, Any]: -> Dict[str, Any]:
fields = {} fields = {}
ko_question = ko_questions.get_by_title(current_ko_criterium) ko_question = ko_questions.get_by_title(current_ko_criterium)
current_app.logger.debug(f"Preparing form for ko_question: {ko_question.to_json()}")
allowed_values = [ko_question.answer_positive, ko_question.answer_negative]
if ko_question.additional_answer_positive:
current_app.logger.debug(f"Additional answer positive found for question {ko_question.title}")
allowed_values.append(ko_question.additional_answer_positive)
if ko_question.additional_answer_negative:
current_app.logger.debug(f"Additional answer negative found for question {ko_question.title}")
allowed_values.append(ko_question.additional_answer_negative)
current_app.logger.debug(f"Allowed values: {allowed_values}")
fields[ko_question.title] = { fields[ko_question.title] = {
"name": ko_question.title, "name": ko_question.title,
"description": ko_question.title, "description": ko_question.title,
"context": ko_question.question, "context": ko_question.question,
"type": "options", "type": "options",
"required": True, "required": True,
"allowed_values": [ko_question.answer_positive, ko_question.answer_negative] "allowed_values": allowed_values
} }
ko_form = { ko_form = {