Skip to content

Commit

Permalink
fix: added misc fixe. updated gpt model
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Nov 19, 2024
1 parent 9184b9b commit 627c99b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
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 });
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

0 comments on commit 627c99b

Please sign in to comment.