Skip to content

Commit

Permalink
Merge branch 'main' into fix/intent_prom
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl authored Nov 28, 2024
2 parents 2b9a15b + 7ec8444 commit baeec8f
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 66 deletions.
22 changes: 17 additions & 5 deletions apps/nextjs/src/components/AppComponents/GetInTouchBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import { useEffect, useState } from "react";

const GetInTouchBox = () => {
const [isFirstRender, setIsFirstRender] = useState(true);
useEffect(() => {
if (isFirstRender) {
setIsFirstRender(false);
}
}, [isFirstRender]);

// Cloudflare has a script to obfuscate emails in the rendered page
// Our CSP policy is blocking it from activating, so we can simulate it ourselves
const email = isFirstRender
? "/cdn-cgi/l/email-protection"
: "mailto:[email protected]";

return (
<div className="flex flex-col items-center gap-14 rounded bg-lavender30 p-19 sm:flex-row">
<div>
Expand Down Expand Up @@ -28,12 +43,9 @@ const GetInTouchBox = () => {
</div>
<p>
Can’t find what you need?{" "}
<a
href="mailto:[email protected]"
className="text-blue underline"
>
<a href={email} className="text-blue underline">
Get in touch
</a>{" "}
</a>
, we’d be happy to help.
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const QuizContent = ({
potentialNewQuestions,
isLoading: suggestedQuestionsLoading,
hasError: suggestedQuestionsHasError,
setPotentialNewQuestion,
setPotentialNewQuestions,
} = useSuggestedQuestions({
state,
dispatch,
Expand Down Expand Up @@ -85,7 +85,7 @@ const QuizContent = ({
potentialNewQuestions={potentialNewQuestions}
dispatch={dispatch}
suggestedQuestionsGeneration={suggestedQuestionsGeneration}
setPotentialNewQuestions={setPotentialNewQuestion}
setPotentialNewQuestions={setPotentialNewQuestions}
questionsWrapperRef={questionsWrapperRef}
questionRefs={questionRefs}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const QuizDesignerPageContent = ({
potentialNewQuestions,
isLoading: suggestedQuestionsLoading,
hasError: suggestedQuestionsHasError,
setPotentialNewQuestion,
setPotentialNewQuestions,
} = useSuggestedQuestions({
state,
dispatch,
Expand Down Expand Up @@ -101,7 +101,7 @@ const QuizDesignerPageContent = ({
suggestedQuestionsHasError={suggestedQuestionsHasError}
potentialNewQuestions={potentialNewQuestions}
dispatch={dispatch}
setPotentialNewQuestions={setPotentialNewQuestion}
setPotentialNewQuestions={setPotentialNewQuestions}
suggestedQuestionsGeneration={suggestedQuestionsGeneration}
questionRefs={questionRefs}
questionsWrapperRef={questionsWrapperRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ModalFooterButtons = ({
<OakLinkNoUnderline
onClick={() => closeDialog()}
element="button"
tabIndex={0}
tabIndex={1}
>
<OakSpan $font="body-2-bold" $color="black" $textDecoration="none">
Cancel
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/components/DialogControl/DialogContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const dialogTitlesAndIcons: Record<
> = {
"share-chat": {
title: "Share lesson",
iconName: "share",
iconName: null,
},
feedback: {
title: "",
iconName: "books",
iconName: null,
},
"report-content": {
title: "Report content",
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/components/Feedback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const FeedBack = ({
{question.question}
</label>
<textarea
tabIndex={0}
tabIndex={1}
className="h-32 w-full min-w-[300px] rounded border-2 border-black p-10"
onChange={(e) => {
setUsersResponse({
Expand All @@ -146,7 +146,7 @@ const FeedBack = ({
})}
<div className="flex justify-center">
<OakPrimaryButton
tabIndex={0}
tabIndex={1}
onClick={() => {
submitSurvey(usersResponse);
onSubmit();
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/src/hooks/useSuggestedQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const useSuggestedQuestions = ({
state,
dispatch,
}: UseSuggestedQuestionsProps) => {
const [potentialNewQuestions, setPotentialNewQuestion] =
const [potentialNewQuestions, setPotentialNewQuestions] =
useState<PotentialQuestionsType>([]);

useEffect(() => {
if (
state.status === QuizAppStatus.EditingSubjectAndKS ||
state.status === QuizAppStatus.Initial
) {
setPotentialNewQuestion([]);
setPotentialNewQuestions([]);
}
}, [state]);

Expand All @@ -60,7 +60,7 @@ const useSuggestedQuestions = ({
});
},
onSuccess: ({ data }) => {
setPotentialNewQuestion(data.response);
setPotentialNewQuestions(data.response);
},
},
);
Expand Down Expand Up @@ -107,7 +107,7 @@ const useSuggestedQuestions = ({
hasError,
potentialNewQuestions,
medianTimeTakenForPrompt,
setPotentialNewQuestion,
setPotentialNewQuestions,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const useTemporaryLessonPlanWithStreamingEdits = ({
// );

return useMemo(() => {
if (!throttledAssistantMessages || !throttledAssistantMessages.length) {
if (!throttledAssistantMessages?.length) {
return {
tempLessonPlan: tempLessonPlanRef.current,
partialPatches: [],
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/lib/hooks/use-copy-to-clipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import * as React from "react";

interface useCopyToClipboardProps {
interface UseCopyToClipboardProps {
timeout?: number;
}

export function useCopyToClipboard({
timeout = 2000,
}: useCopyToClipboardProps) {
}: UseCopyToClipboardProps) {
const [isCopied, setIsCopied] = React.useState<boolean>(false);

const copyToClipboard = (value: string) => {
Expand All @@ -20,7 +20,7 @@ export function useCopyToClipboard({
return;
}

navigator.clipboard.writeText(value).then(() => {
void navigator.clipboard.writeText(value).then(() => {
setIsCopied(true);

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/tests-e2e/tests/aila-chat/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function getSectionsComplete(page: Page): Promise<number> {
const progressText = await page.getByTestId("chat-progress").textContent();
const match = (progressText ?? "").match(/(\d+) of 10 sections complete/);

if (match && match[1]) {
if (match?.[1]) {
return parseInt(match[1], 10);
} else {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/router/testSupport/prepareUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const deleteOldTestUser = async () => {
return;
}

const users = testUsers.sort(
const users = testUsers.toSorted(
(a, b) =>
new Date(a.lastActiveAt ?? a.createdAt).getTime() -
new Date(b.lastActiveAt ?? b.createdAt).getTime(),
Expand All @@ -143,7 +143,7 @@ const deleteOldTestUser = async () => {
log.info(
`${userToDelete.primaryEmailAddress?.emailAddress} already deleted, retrying`,
);
deleteOldTestUser();
await deleteOldTestUser();
} else {
throw e;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/models/lessonPlans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export class LessonPlans {
lessonPlanJsonSchema: JSON.stringify(LessonPlanJsonSchema),
llmResponseJsonSchema: JSON.stringify(LLMResponseJsonSchema),
isUsingStructuredOutput:
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true"
? true
: false,
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true",
});

const systemPrompt = compiledTemplate;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/models/lessons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class Lessons {
lessonId,
quizQuestionId,
}: {
question: { answer?: string | string[] | null | undefined };
question: { answer?: string | string[] | null };
answer: string;
lessonId: string;
quizQuestionId: string;
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/prompts/lesson-assistant/variants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod";

import type { TemplateProps} from ".";
import type { TemplateProps } from ".";
import { getPromptParts } from ".";
import type { OakPromptDefinition, OakPromptVariant } from "../types";

Expand Down Expand Up @@ -59,9 +59,7 @@ export const generateVariants = (): OakPromptVariant[] => {
llmResponseJsonSchema: "<llmResponseJsonSchema>",
lessonPlan: {},
isUsingStructuredOutput:
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true"
? true
: false,
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true",
},
slug,
);
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-config-custom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ module.exports = {
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
plugins:["import"],
parser: "@typescript-eslint/parser",
files: ["*.{ts,tsx}"],
rules: {
"import/no-cycle": "warn",
"import/newline-after-import": "off", // conflict with Prettier
"import/no-duplicates": "off", // conflict with Prettier
"no-console": "warn",
"no-extra-boolean-cast": "warn",
"no-useless-escape": "warn",
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"devDependencies": {
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.1.1",
"typescript": "5.3.3"
Expand Down
3 changes: 3 additions & 0 deletions packages/ingest/src/embedding/handleEmbeddingBatchSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export async function handleEmbeddingBatchSuccess({
continue;
}

if (errors.length > 0) {
log.info(`Errors: ${errors.length}`);
}
lessonIdsCompleted.add(lessonId);
}

Expand Down
Loading

0 comments on commit baeec8f

Please sign in to comment.