Skip to content

Commit

Permalink
Merge pull request #117 from akshat-OwO/main
Browse files Browse the repository at this point in the history
[DEPLOY]
  • Loading branch information
akshat-OwO authored Dec 7, 2024
2 parents 7572830 + 604eeec commit 27a9d7e
Show file tree
Hide file tree
Showing 13 changed files with 1,475 additions and 138 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# syllabusx-client

## 4.10.0

### Minor Changes

- feat [`86ba31`](https://github.com/akshat-OwO/syllabusx-client/commit/86ba317fa6deef359182d98e124af98a7c8fc6c8) [`c4e3fa`](https://github.com/akshat-OwO/syllabusx-client/commit/c4e3fac450a15cd1a42eb665dd2b97a368a38b30): generate mock tests with ai

### Patch Changes

- fix [`82dbdf`](https://github.com/akshat-OwO/syllabusx-client/commit/82dbdfbdae90024089cfda6ae6bedc4c317e17ef): password input for api key
- feat [`5322ab`](https://github.com/akshat-OwO/syllabusx-client/commit/5322ab8cbe147df2635f9d916912c546210570c6): togglable ai summariser
- fix [`82dbdf`](https://github.com/akshat-OwO/syllabusx-client/commit/82dbdfbdae90024089cfda6ae6bedc4c317e17ef): mobile-> subject list button fade over color on hover
- fix [`82dbdf`](https://github.com/akshat-OwO/syllabusx-client/commit/82dbdfbdae90024089cfda6ae6bedc4c317e17ef): scrollable ai features

## 4.9.2

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "syllabusx-client",
"version": "4.9.2",
"version": "4.10.0",
"repository": {
"type": "git",
"url": "https://github.com/akshat-OwO/syllabusx-client.git"
Expand Down Expand Up @@ -42,6 +42,7 @@
"@radix-ui/react-toast": "^1.2.1",
"@radix-ui/react-tooltip": "^1.1.2",
"@react-email/components": "^0.0.14",
"@react-pdf/renderer": "^4.1.5",
"@tailwindcss/typography": "^0.5.13",
"@tanstack/query-sync-storage-persister": "^5.51.9",
"@tanstack/react-query": "^5.51.11",
Expand Down
356 changes: 356 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions src/app/api/google-generate-mock/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { endSemMockTemplate, midSemMockTemplate, newEndSemMockTemplate } from "@/lib/prompt";
import { AiSchema, MockPayloadSchema, MockSchema } from "@/lib/schemas";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { generateObject } from "ai";

export const runtime = "edge";

export async function POST(req: Request) {
const { key, model, maxMarks, semester, branch, subject, topics, type } = await req.json();

const validatedAi = AiSchema.safeParse({ key, model });

if (!validatedAi.success) return Response.json({ error: "Invalid Key" }, { status: 403 });

const validatedPayload = MockPayloadSchema.safeParse({ type, topics, semester, branch, subject });

if (!validatedPayload.success) return Response.json({ error: "Bad Request" }, { status: 400 });

const genAI = createGoogleGenerativeAI({
apiKey: validatedAi.data.key,
});

try {
const { object } = await generateObject({
model: genAI(validatedAi.data.model),
schema: MockSchema,
prompt:
validatedPayload.data.type === "midSem"
? midSemMockTemplate`${semester}${branch}${subject}${topics}`
: maxMarks === 75
? endSemMockTemplate`${semester}${branch}${subject}${topics}`
: newEndSemMockTemplate`${semester}${branch}${subject}${topics}`,
});
return Response.json(object, { status: 200 });
} catch (error) {
return Response.json({ error: "Failed to query llm model" }, { status: 500 });
}
}
36 changes: 36 additions & 0 deletions src/app/api/openai-generate-mock/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createOpenAI } from "@ai-sdk/openai";
import { generateObject } from "ai";
import { AiSchema, MockPayloadSchema, MockSchema } from "@/lib/schemas";
import { endSemMockTemplate, midSemMockTemplate, newEndSemMockTemplate } from "@/lib/prompt";

export const runtime = "edge";

export async function POST(req: Request) {
const { key, model, maxMarks, semester, branch, subject, topics, type } = await req.json();

const validatedAi = AiSchema.safeParse({ key, model });

if (!validatedAi.success) return Response.json({ error: "Invalid Key" }, { status: 403 });

const validatedPayload = MockPayloadSchema.safeParse({ type, topics, semester, branch, subject });

if (!validatedPayload.success) return Response.json({ error: "Bad Request" }, { status: 400 });

const openai = createOpenAI({ apiKey: validatedAi.data.key });

try {
const { object } = await generateObject({
model: openai(validatedAi.data.model),
schema: MockSchema,
prompt:
validatedPayload.data.type === "midSem"
? midSemMockTemplate`${semester}${branch}${subject}${topics}`
: maxMarks === 75
? endSemMockTemplate`${semester}${branch}${subject}${topics}`
: newEndSemMockTemplate`${semester}${branch}${subject}${topics}`,
});
return Response.json(object, { status: 200 });
} catch (error) {
return Response.json({ error: "Failed to query llm model" }, { status: 500 });
}
}
2 changes: 1 addition & 1 deletion src/components/SubjectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SubjectList = ({ course, list }: SubjectListProps) => {
(params.slug[1] ? params.slug[1] : "Select Subject")}
</span>
</div>
<div className="pointer-events-none absolute right-0 top-0 h-full sm:hidden w-12 bg-gradient-to-l from-background to-transparent group-hover:from-secondary transition-colors" />
<div className="pointer-events-none absolute right-0 top-0 h-full sm:hidden w-12 bg-gradient-to-l from-background to-transparent group-hover:from-accent transition-colors" />
</div>
<ChevronsRight className="h-4 w-4" />
</Button>
Expand Down
Loading

1 comment on commit 27a9d7e

@vercel
Copy link

@vercel vercel bot commented on 27a9d7e Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

syllabusx – ./

syllabusx-git-prod-akshat-owo.vercel.app
syllabusx.live
syllabusx-akshat-owo.vercel.app

Please sign in to comment.