Commit c5412e1c authored by Marek Veselý's avatar Marek Veselý
Browse files

Merge branch 'llm-preload' into 'main'

feat: add llm preload platform config setting

See merge request inject/frontend!861
parents 5599d8b2 53c94181
Loading
Loading
Loading
Loading
Compare 9b2723cd to 385b4ad9
Original line number Diff line number Diff line
Subproject commit 9b2723cdc7a4fe3e637fe72820711475fa8d00b9
Subproject commit 385b4ad92e88c98d467b68fe136417c45abcf3d6
+43 −8
Original line number Diff line number Diff line
import { Button, NumericInput, Section, SectionCard } from '@blueprintjs/core'
import {
  Button,
  NumericInput,
  Section,
  SectionCard,
  Switch,
} from '@blueprintjs/core'
import { css } from '@emotion/css'
import {
  GetPlatformConfig,
@@ -37,6 +43,7 @@ type State<
  S = {
    maxTeams: number
    updateInterval: number
    llmPreLoad: boolean
    valid: boolean
  },
> = S & ZustandSetterSingle<S>
@@ -48,6 +55,7 @@ const PlatformConfigForm = () => {
    computed((set, get) => ({
      maxTeams: 0,
      updateInterval: 0,
      llmPreLoad: false,
      ...compute(get, state => ({
        valid: !!state.maxTeams && !!state.updateInterval,
      })),
@@ -66,6 +74,7 @@ const PlatformConfigForm = () => {
    state.setState({
      maxTeams: data?.platformConfig.maxTeams ?? 1,
      updateInterval: data?.platformConfig.updateInterval ?? 1,
      llmPreLoad: data?.platformConfig.llmPreLoad ?? false,
    })
  }, [data, state])

@@ -73,12 +82,12 @@ const PlatformConfigForm = () => {
    <SectionCard className={sectionBody}>
      <ShallowGetSet
        store={state}
        get={({ maxTeams, updateInterval }) =>
          [maxTeams, updateInterval] as const
        get={({ maxTeams, updateInterval, llmPreLoad }) =>
          [maxTeams, updateInterval, llmPreLoad] as const
        }
        set={({ set }) => set}
      >
        {([maxTeams, updateInterval], set) => (
        {([maxTeams, updateInterval, llmPreLoad], set) => (
          <>
            <Section
              title={t('platformConfig.maxTeams.title')}
@@ -113,22 +122,47 @@ const PlatformConfigForm = () => {
                />
              }
            />
            <Section
              title={t('platformConfig.llmPreLoad.title')}
              subtitle={t('platformConfig.llmPreLoad.description')}
              className={section}
              rightElement={
                <div
                  className={css`
                    min-width: 12rem !important;
                    display: flex;
                    justify-content: flex-end;
                  `}
                >
                  <Switch
                    checked={llmPreLoad}
                    onChange={e => set('llmPreLoad', e.currentTarget.checked)}
                    label={
                      llmPreLoad
                        ? t('platformConfig.llmPreLoad.enabled')
                        : t('platformConfig.llmPreLoad.disabled')
                    }
                  />
                </div>
              }
            />
          </>
        )}
      </ShallowGetSet>
      <ShallowGet
        store={state}
        get={({ maxTeams, updateInterval, valid }) =>
          [maxTeams, updateInterval, valid] as const
        get={({ maxTeams, updateInterval, llmPreLoad, valid }) =>
          [maxTeams, updateInterval, llmPreLoad, valid] as const
        }
      >
        {([maxTeams, updateInterval, valid]) => (
        {([maxTeams, updateInterval, llmPreLoad, valid]) => (
          <Button
            disabled={
              updateLoading ||
              !valid ||
              (maxTeams === data?.platformConfig.maxTeams &&
                updateInterval === data.platformConfig.updateInterval)
                updateInterval === data.platformConfig.updateInterval &&
                llmPreLoad === data.platformConfig.llmPreLoad)
            }
            intent={'primary'}
            className={css`
@@ -140,6 +174,7 @@ const PlatformConfigForm = () => {
                platformConfigInput: {
                  maxTeams,
                  updateInterval,
                  llmPreLoad,
                },
              })
            }}
+1 −0
Original line number Diff line number Diff line
@@ -2376,6 +2376,7 @@ export const PlatformConfig = graphql(
      id
      maxTeams
      updateInterval
      llmPreLoad
    }
  `,
  []
+5 −5
Original line number Diff line number Diff line
@@ -252,8 +252,8 @@ declare module 'gql.tada' {
      TadaDocumentNode<{ addedAt: string; id: string; domain: string; addedBy: { id: string; username: string; } | null; }, {}, { fragment: "DomainRestriction"; on: "DomainRestrictionType"; masked: false; }>;
    "\n    fragment InstructorCommentWithActionLog on InstructorCommentType @_unmask {\n      ...InstructorComment\n      actionLog {\n        ...InstructorCommentActionLog\n      }\n    }\n  ":
      TadaDocumentNode<{ id: string; comment: string; createdAt: string; createdBy: { __typename?: "IUserType" | undefined; id: string; username: string; } | { __typename?: "TUserType" | undefined; id: string; username: string; } | null; score: number; teamId: string; actionLog: { __typename: "TActionLogType"; id: string; logType: "EMAIL" | "FORM" | "TOOL" | "CONFIRMATION" | "CUSTOM_INJECT" | "FILE_DOWNLOAD" | "FORM_REVIEW" | "FORM_SUBMISSION" | "INJECT" | "MILESTONE_MODIFICATION" | "SANDBOX_LOG"; timestamp: string; inExerciseTime: number; team: { name: string; }; details: { __typename: "TTeamQuestionnaireStateType"; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; questionnaire: { id: string; displayName: string; questions: { id: string; details: { __typename: "FreeFormQuestionDetailsType"; id: string; relatedMilestones: { id: string; }[]; } | { __typename: "AutoFreeFormQuestionDetailsType"; } | { __typename: "MultipleChoiceQuestionDetailsType"; } | { __typename: "RadioQuestionDetailsType"; }; }[]; }; } | { __typename: "TConfirmationDetailsType"; } | { __typename: "TCustomInjectDetailsType"; } | { __typename: "TEmailType"; id: string; thread: { id: string; subject: string; }; } | { __typename: "TFileDownloadDetailsType"; } | { __typename: "TInjectDetailsType"; } | { __typename: "TMilestoneModificationDetailsType"; } | { __typename: "TQuestionnaireReviewDetailsType"; } | { __typename: "TQuestionnaireSubmissionType"; id: string; accepted: boolean; teamQuestionnaireState: { __typename?: "TTeamQuestionnaireStateType" | undefined; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; } | { __typename?: "ITeamQuestionnaireStateType" | undefined; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; }; answers: { id: string; question: { id: string; details: { __typename: "FreeFormQuestionDetailsType"; id: string; relatedMilestones: { id: string; }[]; } | { __typename: "AutoFreeFormQuestionDetailsType"; } | { __typename: "MultipleChoiceQuestionDetailsType"; } | { __typename: "RadioQuestionDetailsType"; }; }; }[]; } | { __typename: "TSandboxLogDetailsType"; } | { __typename: "TToolDetailsType"; id: string; tool: { id: string; displayName: string; }; }; } | { __typename: "IActionLogType"; id: string; logType: "EMAIL" | "FORM" | "TOOL" | "CONFIRMATION" | "CUSTOM_INJECT" | "FILE_DOWNLOAD" | "FORM_REVIEW" | "FORM_SUBMISSION" | "INJECT" | "MILESTONE_MODIFICATION" | "SANDBOX_LOG"; timestamp: string; inExerciseTime: number; team: { name: string; }; details: { __typename: "ITeamQuestionnaireStateType"; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; questionnaire: { id: string; displayName: string; questions: { id: string; details: { __typename: "FreeFormQuestionDetailsType"; id: string; relatedMilestones: { id: string; }[]; } | { __typename: "AutoFreeFormQuestionDetailsType"; } | { __typename: "MultipleChoiceQuestionDetailsType"; } | { __typename: "RadioQuestionDetailsType"; }; }[]; }; } | { __typename: "IConfirmationDetailsType"; } | { __typename: "ICustomInjectDetailsType"; } | { __typename: "IEmailType"; id: string; thread: { id: string; subject: string; }; } | { __typename: "IFileDownloadDetailsType"; } | { __typename: "IInjectDetailsType"; } | { __typename: "IMilestoneModificationDetailsType"; } | { __typename: "IQuestionnaireReviewDetailsType"; } | { __typename: "IQuestionnaireSubmissionType"; id: string; accepted: boolean; teamQuestionnaireState: { __typename?: "TTeamQuestionnaireStateType" | undefined; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; } | { __typename?: "ITeamQuestionnaireStateType" | undefined; id: string; status: "ANSWERED" | "DELAYED" | "REVIEWED" | "SENT" | "UNSENT"; }; answers: { id: string; question: { id: string; details: { __typename: "FreeFormQuestionDetailsType"; id: string; relatedMilestones: { id: string; }[]; } | { __typename: "AutoFreeFormQuestionDetailsType"; } | { __typename: "MultipleChoiceQuestionDetailsType"; } | { __typename: "RadioQuestionDetailsType"; }; }; }[]; } | { __typename: "ISandboxLogDetailsType"; } | { __typename: "IToolDetailsType"; id: string; tool: { id: string; displayName: string; }; }; }; }, {}, { fragment: "InstructorCommentWithActionLog"; on: "InstructorCommentType"; masked: false; }>;
    "\n    fragment PlatformConfig on PlatformConfigType @_unmask {\n      id\n      maxTeams\n      updateInterval\n    }\n  ":
      TadaDocumentNode<{ id: string; maxTeams: number; updateInterval: number; }, {}, { fragment: "PlatformConfig"; on: "PlatformConfigType"; masked: false; }>;
    "\n    fragment PlatformConfig on PlatformConfigType @_unmask {\n      id\n      maxTeams\n      updateInterval\n      llmPreLoad\n    }\n  ":
      TadaDocumentNode<{ id: string; maxTeams: number; updateInterval: number; llmPreLoad: boolean; }, {}, { fragment: "PlatformConfig"; on: "PlatformConfigType"; masked: false; }>;
    "\n    fragment NoticeboardMessage on NoticeboardMessageType @_unmask {\n      id\n      content\n      expiresAt\n      createdBy {\n        ...TUser\n      }\n    }\n  ":
      TadaDocumentNode<{ id: string; content: string; expiresAt: string; createdBy: { __typename: "TUserType"; id: string; username: string; firstName: string | null; lastName: string | null; group: "ADMIN" | "BOT" | "INSTRUCTOR" | "TRAINEE"; lastLogin: string | null; dateJoined: string; isGuest: boolean; } | null; }, {}, { fragment: "NoticeboardMessage"; on: "NoticeboardMessageType"; masked: false; }>;
    "\n    fragment LLMAssessment on LLMAssessmentType @_unmask {\n      id\n      persona\n      assessment\n    }\n  ":
@@ -385,7 +385,7 @@ declare module 'gql.tada' {
    "\n    query ExerciseStatusQuery($exerciseId: ID!) {\n      exerciseId(exerciseId: $exerciseId) {\n        id\n        onDemand\n        states {\n          id\n          status\n          teams {\n            id\n          }\n        }\n      }\n    }\n  ":
      TadaDocumentNode<{ exerciseId: { id: string; onDemand: boolean; states: { id: string; status: "EXPIRED" | "FINISHED" | "NOT_STARTED" | "PAUSED" | "RUNNING" | "STOPPED"; teams: { id: string; }[]; }[]; }; }, { exerciseId: string; }, void>;
    "\n    query GetPlatformConfig {\n      platformConfig {\n        ...PlatformConfig\n      }\n    }\n  ":
      TadaDocumentNode<{ platformConfig: { id: string; maxTeams: number; updateInterval: number; }; }, {}, void>;
      TadaDocumentNode<{ platformConfig: { id: string; maxTeams: number; updateInterval: number; llmPreLoad: boolean; }; }, {}, void>;
    "\n    query NoticeboardMessagesQuery($includeExpired: Boolean) {\n      noticeboardMessages(includeExpired: $includeExpired) {\n        ...NoticeboardMessage\n      }\n    }\n  ":
      TadaDocumentNode<{ noticeboardMessages: { id: string; content: string; expiresAt: string; createdBy: { __typename: "TUserType"; id: string; username: string; firstName: string | null; lastName: string | null; group: "ADMIN" | "BOT" | "INSTRUCTOR" | "TRAINEE"; lastLogin: string | null; dateJoined: string; isGuest: boolean; } | null; }[]; }, { includeExpired?: boolean | null | undefined; }, void>;
    "\n    query UserTeamTokenQuery($teamId: ID!) {\n      userTeamToken(teamId: $teamId)\n    }\n  ":
@@ -496,8 +496,8 @@ declare module 'gql.tada' {
      TadaDocumentNode<{ createDomainRestriction: { newDomain: { id: string; }; } | null; }, { domainName: string; }, void>;
    "\n    mutation DeleteDomainRestriction($domainId: ID!) {\n      deleteDomainRestriction(domainId: $domainId) {\n        operationDone\n      }\n    }\n  ":
      TadaDocumentNode<{ deleteDomainRestriction: { operationDone: boolean; } | null; }, { domainId: string; }, void>;
    "\n  mutation UpdatePlatformConfig($platformConfigInput: PlatformConfigInput!) {\n    updatePlatformConfig(platformConfigInput: $platformConfigInput) {\n      platformConfig {\n        id\n        maxTeams\n        updateInterval\n      }\n    }\n  }\n":
      TadaDocumentNode<{ updatePlatformConfig: { platformConfig: { id: string; maxTeams: number; updateInterval: number; }; } | null; }, { platformConfigInput: { updateInterval?: number | null | undefined; maxTeams?: number | null | undefined; llmPreLoad?: boolean | null | undefined; }; }, void>;
    "\n    mutation UpdatePlatformConfig($platformConfigInput: PlatformConfigInput!) {\n      updatePlatformConfig(platformConfigInput: $platformConfigInput) {\n        platformConfig {\n          ...PlatformConfig\n        }\n      }\n    }\n  ":
      TadaDocumentNode<{ updatePlatformConfig: { platformConfig: { id: string; maxTeams: number; updateInterval: number; llmPreLoad: boolean; }; } | null; }, { platformConfigInput: { updateInterval?: number | null | undefined; maxTeams?: number | null | undefined; llmPreLoad?: boolean | null | undefined; }; }, void>;
    "\n    mutation CreateNoticeboardMessage(\n      $content: String!\n      $expiration: DateTime!\n    ) {\n      createNoticeboardMessage(content: $content, expiration: $expiration) {\n        message {\n          ...NoticeboardMessage\n        }\n      }\n    }\n  ":
      TadaDocumentNode<{ createNoticeboardMessage: { message: { id: string; content: string; expiresAt: string; createdBy: { __typename: "TUserType"; id: string; username: string; firstName: string | null; lastName: string | null; group: "ADMIN" | "BOT" | "INSTRUCTOR" | "TRAINEE"; lastLogin: string | null; dateJoined: string; isGuest: boolean; } | null; } | null; } | null; }, { expiration: string; content: string; }, void>;
    "\n    mutation DeleteNoticeboardMessage($messageIds: [ID!]!) {\n      deleteNoticeboardMessages(messageIds: $messageIds) {\n        deletedMessageIds\n      }\n    }\n  ":
+10 −9
Original line number Diff line number Diff line
@@ -639,17 +639,18 @@ export const DeleteDomainRestriction = graphql(
  []
)

export const UpdatePlatformConfig = graphql(`
export const UpdatePlatformConfig = graphql(
  `
    mutation UpdatePlatformConfig($platformConfigInput: PlatformConfigInput!) {
      updatePlatformConfig(platformConfigInput: $platformConfigInput) {
        platformConfig {
        id
        maxTeams
        updateInterval
          ...PlatformConfig
        }
      }
    }
`)
  `,
  [Fragments.PlatformConfig]
)

export const CreateNoticeboardMessage = graphql(
  `
Loading