Commit 159c5694 authored by Richard Glosner's avatar Richard Glosner
Browse files

Merge branch...

Merge branch '544-implement-be-support-for-ai-assessment-of-emails-and-free-form-question-answers' into 'main'

Resolve "Implement BE support for AI assessment of emails and free-form question answers"

See merge request inject/backend!479
parents 8a2775de 066a8da4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ from exercise_definition.models import (
    AutoFreeFormQuestion,
    MultipleChoiceQuestion,
    Repeatable,
    LLMAssessment,
)
from running_exercise.lib.utils import can_show_instructor_comments
from running_exercise.models import (
@@ -143,6 +144,11 @@ class ContentType(DjangoObjectType):
        )


class LLMAssessmentType(DjangoObjectType):
    class Meta:
        model = LLMAssessment


class ConfigType(DjangoObjectType):
    class Meta:
        model = Config
@@ -519,6 +525,7 @@ class FreeFormQuestionDetailsType(DjangoObjectType):
        graphene.NonNull(MilestoneType), required=True
    )
    definition = graphene.Field(ExerciseDefinitionType, required=True)
    llm_assessment = graphene.Field(LLMAssessmentType, required=False)

    def resolve_related_milestones(self, info):
        # TODO: Use an actual exercise access object (difficult because we do not have a team/exercise id here)
@@ -529,6 +536,13 @@ class FreeFormQuestionDetailsType(DjangoObjectType):

        return Milestone.objects.filter(id__in=self.related_milestones)

    def resolve_llm_assessment(self, info):
        user = user_from_context(info.context)
        if user.group == User.AuthGroup.TRAINEE:
            return LLMAssessment.objects.none()

        return self.llm_assessment


class AutoFreeFormQuestionDetailsType(DjangoObjectType):
    class Meta:
+15 −0
Original line number Diff line number Diff line
## 0.24.6
Issues: inject/backend#544, inject/inject-issues#240

Added new object `llm assessment` for the free-form questions and email addresses.
This object contains the following attributes:
- `persona` or `persona_path`: The system prompt for the LLM defining the behaviour and persona of the LLM
- `assessment` or `assessment_path`: Prompt with specific task context and instructions for assessment.

### email.yml
- added optional field `llm_assessment` to email addresses

### questionnaires.yml
- added optional field `llm_assessment` to free-form question


## 0.24.5
Issues: inject/backend#543, inject/inject-issues#167

+26 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ questionnaires.yml
objectives.yml
```

`content/`, `files/` and `drive/` directories are optional.
`content/`, `files/`, `drive/`, and `llm/` directories are optional.
They do not need to be present if your definition does not use the relevant features.

Furthermore, it is possible to use a directory instead of a single YAML file.
@@ -137,6 +137,29 @@ specification of an overlay _without_ a set duration is done like so:
    overlay: {}
```

#### LLM-assessment

- **persona**: _str, default=""_ - system prompt for the LLM defining the behaviour and persona of the LLM
- **persona_path**: _str, default=""_ - name of a text/markdown file that contains the persona
- **assessment**: _str, default=""_ - prompt with specific task context and instructions for assessment and required response format
- **assessment_path**: _str, default=""_ - name of a text/markdown file that contains the assessment

Either `persona` or `persona_path` must be specified.
Either `assessment` or `assessment_path` must be specified.
If `..._path` is used, the file with the given name must be present inside `llm/` directory in the definition.


This object allows to specify a persona and assessment for the given:
- `email address`
- `question` (only free-form type)

The `llm_assessment` can be created for situations where a longer input is expected to be sent by trainee either:
- in an email to a ceratin `email address` or
- in an answer to a (free-form) `question`

Clear instructions for the LLM behaviour and role should be provided in `persona`.
The `assessment` should contain clear instructions for assessment of the trainees input and additional data (what kind of input did the trainee provide, what should be assessed, how, what the output of the LLM should contains,...).

### drive

This optional directory can be included in the definition to use the internal drive feature.
@@ -368,6 +391,7 @@ This file contains all email addresses where each address has the following fiel
    - **content**: _[content](#content), default=empty_
    - **control**: _[control](#control), default=empty_ - milestone condition and roles cannot be specified,
      milestone modifications are triggered once the template is sent
- **llm_assessment**: _[llm assessment](#llm-assessment), default=empty_

### roles.yml

@@ -464,6 +488,7 @@ Each questionnaire has the following fields:
  `0` means that an empty answer will be accepted
- **max**: _int, default=-1_ - optional field that specifies the maximum length of the answer to be accepted,
  `-1` signifies no requirement
- **llm_assessment**: _[llm assessment](#llm-assessment), default=empty_ -

#### Question: auto-free-form

+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ exercise_duration: 60
show_exercise_time: False
show_exercise_overview: True
instructor_required: True
version: 0.24.5
version: 0.24.6
description: Some description about this definition.
instructor_notes: { content: Some notes about this definition }
target_audience: Some description of target audience
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ exercise_duration: 60
email_between_teams: True
show_exercise_time: False
instructor_required: False
version: 0.24.5
version: 0.24.6
description: |
  Long description about this definition.Long description about this definition.Long description about this definition.
  Long description about this definition.Long description about this definition.Long description about this definition.
Loading