Skip to content

Commit 2bd81f6

Browse files
committed
chore: add prettierrc file and conver to singlequote
1 parent dba43c7 commit 2bd81f6

File tree

553 files changed

+12759
-12822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

553 files changed

+12759
-12822
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ""
5-
labels: ""
6-
assignees: ""
4+
title: ''
5+
labels: ''
6+
assignees: ''
77
---
88

99
**Describe the bug**

.github/ISSUE_TEMPLATE/feature_request.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ""
5-
labels: ""
6-
assignees: ""
4+
title: ''
5+
labels: ''
6+
assignees: ''
77
---
88

99
**Is your feature request related to a problem? Please describe.**

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}
+54-54
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
"use server";
1+
'use server'
22
// lib
3-
import { openai } from "@/lib/open-ai";
4-
import { prisma } from "@/lib/prisma";
5-
import { answerHelpSchema } from "@/lib/zod/schemas/ai/answer-help";
3+
import { openai } from '@/lib/open-ai'
4+
import { prisma } from '@/lib/prisma'
5+
import { answerHelpSchema } from '@/lib/zod/schemas/ai/answer-help'
66

77
// helpers
8-
import { getPrompt } from "../utils/get-prompt";
9-
import { getUser } from "@/actions/user/authed/get-user";
10-
import { zodResponseFormat } from "openai/helpers/zod.mjs";
8+
import { getPrompt } from '../utils/get-prompt'
9+
import { getUser } from '@/actions/user/authed/get-user'
10+
import { zodResponseFormat } from 'openai/helpers/zod.mjs'
1111

1212
// types
13-
import type { UserRecord } from "@/types/User";
13+
import type { UserRecord } from '@/types/User'
1414
import type {
1515
DefaultRoadmapQuestions,
1616
RoadmapUserQuestions,
17-
} from "@/types/Roadmap";
18-
import type { Question } from "@/types/Questions";
17+
} from '@/types/Roadmap'
18+
import type { Question } from '@/types/Questions'
1919

2020
const answerHelp = async (
2121
userCorrect: boolean,
2222
user: UserRecord,
2323
question: Question | RoadmapUserQuestions | DefaultRoadmapQuestions,
2424
) => {
2525
const answerHelpPrompt = await getPrompt({
26-
name: "question-answer-help",
27-
});
26+
name: 'question-answer-help',
27+
})
2828

2929
const answerHelp = await openai.chat.completions.create({
30-
model: "gpt-4o-mini-2024-07-18",
30+
model: 'gpt-4o-mini-2024-07-18',
3131
temperature: 0,
3232
messages: [
3333
{
34-
role: "system",
35-
content: answerHelpPrompt["question-answer-help"].content,
34+
role: 'system',
35+
content: answerHelpPrompt['question-answer-help'].content,
3636
},
3737
{
38-
role: "system",
38+
role: 'system',
3939
content:
40-
"The user answered correctly: " +
41-
(userCorrect ? "true" : "false") +
42-
". This is the reason as to why the user is asking for help: " +
40+
'The user answered correctly: ' +
41+
(userCorrect ? 'true' : 'false') +
42+
'. This is the reason as to why the user is asking for help: ' +
4343
(userCorrect
44-
? "The user answered correctly"
45-
: "The user answered incorrectly, provide a more detailed explanation"),
44+
? 'The user answered correctly'
45+
: 'The user answered incorrectly, provide a more detailed explanation'),
4646
},
4747
{
48-
role: "system",
48+
role: 'system',
4949
content:
50-
"The user has provided the following information about themselves, tailor your answer to this information:",
50+
'The user has provided the following information about themselves, tailor your answer to this information:',
5151
},
5252
{
53-
role: "user",
54-
content: user?.aboutMeAiHelp || "",
53+
role: 'user',
54+
content: user?.aboutMeAiHelp || '',
5555
},
5656
{
57-
role: "user",
58-
content: question.codeSnippet || "",
57+
role: 'user',
58+
content: question.codeSnippet || '',
5959
},
6060
],
61-
response_format: zodResponseFormat(answerHelpSchema, "event"),
62-
});
61+
response_format: zodResponseFormat(answerHelpSchema, 'event'),
62+
})
6363

6464
if (!answerHelp.choices[0]?.message?.content) {
65-
throw new Error("AI response is missing content");
65+
throw new Error('AI response is missing content')
6666
}
6767

68-
return JSON.parse(answerHelp.choices[0].message.content);
69-
};
68+
return JSON.parse(answerHelp.choices[0].message.content)
69+
}
7070

7171
/**
7272
* Method to generate answer help for both regular and roadmap questions.
@@ -80,36 +80,36 @@ const answerHelp = async (
8080
export const generateAnswerHelp = async (
8181
questionUid: string,
8282
userCorrect: boolean,
83-
questionType: "regular" | "roadmap" | "onboarding",
83+
questionType: 'regular' | 'roadmap' | 'onboarding',
8484
) => {
85-
const user = await getUser();
85+
const user = await getUser()
8686

8787
if (!user) {
8888
return {
8989
content: null,
9090
tokensUsed: 0,
91-
};
91+
}
9292
}
9393

9494
// For regular questions, check if the user has enough tokens
9595
if (
96-
questionType === "regular" &&
96+
questionType === 'regular' &&
9797
user.aiQuestionHelpTokens &&
9898
user.aiQuestionHelpTokens <= 0
9999
) {
100100
return {
101101
content: null,
102102
tokensUsed: 0,
103-
};
103+
}
104104
}
105105

106106
let question:
107107
| Question
108108
| RoadmapUserQuestions
109109
| DefaultRoadmapQuestions
110-
| null = null;
110+
| null = null
111111

112-
if (questionType === "roadmap") {
112+
if (questionType === 'roadmap') {
113113
// Get the roadmap question
114114
question = (await prisma.roadmapUserQuestions.findUnique({
115115
where: {
@@ -123,56 +123,56 @@ export const generateAnswerHelp = async (
123123
include: {
124124
answers: true,
125125
},
126-
})) as RoadmapUserQuestions | null;
127-
} else if (questionType === "regular") {
126+
})) as RoadmapUserQuestions | null
127+
} else if (questionType === 'regular') {
128128
// Get the regular question
129129
question = await prisma.questions.findUnique({
130130
where: { uid: questionUid },
131131
include: {
132132
answers: true,
133133
},
134-
});
135-
} else if (questionType === "onboarding") {
134+
})
135+
} else if (questionType === 'onboarding') {
136136
// Get the onboarding question
137137
question = await prisma.defaultRoadmapQuestions.findUnique({
138138
where: { uid: questionUid },
139139
include: {
140140
answers: true,
141141
},
142-
});
142+
})
143143
}
144144

145145
if (!question) {
146-
console.error("Question not found");
146+
console.error('Question not found')
147147
return {
148148
content: null,
149149
tokensUsed: 0,
150-
};
150+
}
151151
}
152152

153153
// Generate the answer help
154-
const formattedData = await answerHelp(userCorrect, user, question);
154+
const formattedData = await answerHelp(userCorrect, user, question)
155155

156156
// Handle token decrement for regular questions
157157
if (
158-
questionType === "regular" &&
159-
user.userLevel !== "PREMIUM" &&
160-
user.userLevel !== "ADMIN"
158+
questionType === 'regular' &&
159+
user.userLevel !== 'PREMIUM' &&
160+
user.userLevel !== 'ADMIN'
161161
) {
162162
const updatedUser = await prisma.users.update({
163163
where: { uid: user.uid },
164164
data: { aiQuestionHelpTokens: { decrement: 1 } },
165-
});
165+
})
166166

167167
return {
168168
content: formattedData,
169169
tokensUsed: updatedUser.aiQuestionHelpTokens,
170-
};
170+
}
171171
}
172172

173173
// For roadmap questions or premium users, return infinite tokens
174174
return {
175175
content: formattedData,
176176
tokensUsed: Number.POSITIVE_INFINITY,
177-
};
178-
};
177+
}
178+
}

0 commit comments

Comments
 (0)