Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ai models. fix bugs #162

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/registry/app/[username]/letter/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useSearchParams } from 'next/navigation';
import ReactMarkdown from 'react-markdown';
import Hero from '../../../src/ui/Hero';
import Loading from '../../components/Loading';
import { track } from '@vercel/analytics/server';

export default function Letter({ params }) {
const searchParams = useSearchParams();
Expand All @@ -30,7 +29,6 @@ export default function Letter({ params }) {

useEffect(() => {
if (submitting) {
track('ResumeLetter', { username });
const fetchData = async () => {
try {
const response = await axios.post('/api/letter', {
Expand Down
2 changes: 0 additions & 2 deletions apps/registry/app/[username]/suggestions/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useEffect, useState } from 'react';
import Hero from '../../../src/ui/Hero';
import ReactMarkdown from 'react-markdown';
import Loading from '../../components/Loading';
import { track } from '@vercel/analytics/server';

export default function Suggestions({ params }) {
const { username } = params;
Expand All @@ -16,7 +15,6 @@ export default function Suggestions({ params }) {

useEffect(() => {
if (submitting) {
track('ResumeSuggestions', { username });
const fetchData = async () => {
try {
const response = await axios.post('/api/suggestions', {
Expand Down
10 changes: 7 additions & 3 deletions apps/registry/lib/calculations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nlp from 'compromise';
* @returns {Object} - An object containing the total work experience in years, months, and days.
*/
export function totalExperience(resume) {
const workHistory = resume.work;
const workHistory = resume.work || [];
const dateRanges = workHistory.map((job) => ({
startDate: new Date(job.startDate),
endDate: job.endDate ? new Date(job.endDate) : new Date(),
Expand All @@ -17,7 +17,7 @@ export function totalExperience(resume) {
dateRanges.sort((a, b) => a.startDate - b.startDate);

// Merge overlapping date ranges
const mergedRanges = [];
let mergedRanges = [];
let currentRange = dateRanges[0];

for (let i = 1; i < dateRanges.length; i++) {
Expand All @@ -39,7 +39,11 @@ export function totalExperience(resume) {
// Calculate total experience from merged ranges
let totalExperienceInDays = 0;

// Remove undefined or invalid date ranges
mergedRanges = mergedRanges.filter(Boolean);

mergedRanges.forEach((range) => {
console.log({ range, mergedRanges });
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove debugging console.log statement.

Production code should not contain debugging console.log statements as they can pollute logs and impact performance.

Apply this diff:

-    console.log({ range, mergedRanges });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log({ range, mergedRanges });

const experience =
(range.endDate - range.startDate) / (1000 * 60 * 60 * 24); // Convert milliseconds to days
totalExperienceInDays += experience;
Expand Down Expand Up @@ -127,7 +131,7 @@ export function averageJobDuration(resume) {
* @returns {Array} - An array of objects representing the career progression with title and duration in years and months.
*/
export function careerProgression(resume) {
const workHistory = resume.work;
const workHistory = resume.work || [];
const progressionMap = new Map();

workHistory.forEach((job) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/registry/pages/api/letter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default async function handler(req, res) {

const gpt = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
model: 'gpt-4o-2024-08-06',
model: 'gpt-4o-mini',
completionParams: {
temperature: 0.85,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/registry/pages/api/suggestions-beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default async function handler(req, res) {
];

const chat = await openai.chat.completions.create({
model: 'gpt-4o-2024-08-06',
model: 'gpt-4o-mini',
temperature: 0.7,
messages,
functions,
Expand Down
2 changes: 1 addition & 1 deletion apps/registry/pages/api/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default async function handler(req, res) {
];

const chat = await openai.chat.completions.create({
model: 'gpt-4o-2024-08-06',
model: 'gpt-4o-mini',
temperature: 0.85,
messages,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/registry/scripts/jobs/gpted.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async function main() {
];
if (!job.gpt_content) {
const chat = await openai.chat.completions.create({
model: 'gpt-4o-2024-08-06',
model: 'gpt-4o-mini',
temperature: 0.8,
messages,
functions: [
Expand Down
Loading
Loading