stages/prompt: set field placeholder based on plan context

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-08 14:47:50 +01:00
parent da74304221
commit c3faa61ed9
1 changed files with 7 additions and 1 deletions

View File

@ -164,10 +164,16 @@ class PromptStageView(ChallengeStageView):
def get_challenge(self, *args, **kwargs) -> Challenge: def get_challenge(self, *args, **kwargs) -> Challenge:
fields = list(self.executor.current_stage.fields.all().order_by("order")) fields = list(self.executor.current_stage.fields.all().order_by("order"))
serializers = []
context_prompt = self.executor.plan.get(PLAN_CONTEXT_PROMPT, {})
for field in fields:
data = StagePromptSerializer(field).data
data["placeholder"] = context_prompt.get(field.field_key)
serializers.append(data)
challenge = PromptChallenge( challenge = PromptChallenge(
data={ data={
"type": ChallengeTypes.NATIVE.value, "type": ChallengeTypes.NATIVE.value,
"fields": [StagePromptSerializer(field).data for field in fields], "fields": serializers,
}, },
) )
return challenge return challenge