Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Add AI Job matching with resume feature
Khuram Niaz89a7a48969e3
diff --git a/src/actions/ai.actions.ts b/src/actions/ai.actions.tsindex 6a2b905..2cb0656 100644--- a/src/actions/ai.actions.ts+++ b/src/actions/ai.actions.ts@@ -5,14 +5,9 @@ import { HumanMessage, SystemMessage } from "@langchain/core/messages";import { ChatOllama } from "@langchain/community/chat_models/ollama";import { StringOutputParser } from "@langchain/core/output_parsers";import { ChatPromptTemplate } from "@langchain/core/prompts";-import {- ContactInfo,- Education,- Resume,- ResumeSection,- SectionType,- WorkExperience,-} from "@/models/profile.model";+import { Resume } from "@/models/profile.model";+import { JobResponse } from "@/models/job.model";+import { convertJobToText, convertResumeToText } from "@/utils/ai.utils";export const getResumeReviewByAi = async (resume: Resume,@@ -51,13 +46,13 @@ export const getResumeReviewByAi = async (],]);- const resumeText = convertResumeToText(resume);+ const resumeText = await convertResumeToText(resume);const inputMessage = await prompt.format({ resume: resumeText });const model = new ChatOllama({baseUrl: process.env.OLLAMA_BASE_URL || "http://127.0.0.1:11434",- model: "llama3",+ model: "llama3.1",temperature: 0,format: "json",});@@ -79,84 +74,95 @@ export const getResumeReviewByAi = async (});};-const convertResumeToText = (resume: Resume) => {- const formatContactInfo = (contactInfo?: ContactInfo) => {- if (!contactInfo) return "";- return `- Name: ${contactInfo.firstName} ${contactInfo.lastName}- Headline: ${contactInfo.headline}- Email: ${contactInfo.email || "N/A"}- Phone: ${contactInfo.phone || "N/A"}- Address: ${contactInfo.address || "N/A"}- `;- };-- const formatWorkExperiences = (workExperiences?: WorkExperience[]) => {- if (!workExperiences || workExperiences.length === 0) return "";- return workExperiences- .map(- (experience) => `- Company: ${experience.Company.label}- Job Title: ${experience.jobTitle.label}- Location: ${experience.location.label}- Description: ${experience.description}+export const getJobMatchByAi = async (+ resume: Resume,+ job: JobResponse,+ modelProvider?: string+): Promise<any | undefined> => {+ const resumeText = await convertResumeToText(resume);+ const jobText = await convertJobToText(job);++ const prompt = ChatPromptTemplate.fromMessages([+ [+ "system",`- )- .join("\n");- };- // Start Date: ${experience.startDate.toLocaleDateString().split("T")[0]}- // End Date: ${- // experience.currentJob- // ? "Present"- // : experience.endDate.toLocaleDateString().split("T")[0]- // }-- const formatEducation = (educations?: Education[]) => {- if (!educations || educations.length === 0) return "";- return (- educations- .map(- (education) => `- Institution: ${education.institution}- Degree: ${education.degree}- Field of Study: ${education.fieldOfStudy}- Location: ${education.location}- Description: ${education.description || "N/A"}+ You are an expert assistant tasked with matching job seekers' resumes with job descriptions and providing suggestions to improve their resumes.+ You will analyze the given resume and job description, provide a matching score between 0 and 100,+ score will be based on application tracking system (ATS) friendliness and skill and keywords match,+ and suggest improvements to increase the matching score and make the resume more aligned with the job description.+ Be verbose and highlight details in your response.++ Your response must always return JSON object with following structure:++ "matching_score": <matching_score with single numeric value, be strict with this score with always room for improvement>,+ "detailed_analysis": an array list of following object structures:+ <<object structure>>+ "category": "suggestion category title with score",+ "value": "an array list of suggestion as strings",+ <<example 1>>+ "category": "ATS Friendliness(60/100):",+ "value": ["<ATS friendliness analysis 1>", "<ATS friendliness analysis 2>",...],+ <<example 2>>+ "category": "Skill and Keyword match(65/100):",+ "value": ["<description of analysis in terms of skill match>", "<description of analysis in terms of keyword match>",...],+ "suggestions": an array list with following object structures:+ <<object structure>>+ "category": "suggestion category title",+ "value": "an array list of suggestion as strings",+ <<example 1>>+ "category": "Emphasize Keywords and Skills:",+ "value": ["<missing keywords not found in resume>", "<missing skill not found in resume>",...],+ <<example 2>>+ "category": "Format for clarity and ATS optimization:",+ "value": ["<suggested_change 1>", "<suggested_change 2>",...],+ <<example 3>>+ "category": "Enhancement for relevant experience:",+ "value": ["<suggested_change 1>", "<suggested_change 2>",...],+ "additional_comments": summary of recommendations as array of strings.+ <<example>>+ ["<brief summary description>"],+ `,+ ],+ [+ "human",`- )- // Start Date: ${education.startDate.toLocaleDateString().split("T")[0]}- // End Date: ${- // education.endDate- // ? education.endDate.toLocaleDateString().split("T")[0]- // : "N/A"- // }- .join("\n")- );- };-- const formatResumeSections = (sections?: ResumeSection[]) => {- if (!sections || sections.length === 0) return "";- return sections- .map((section) => {- switch (section.sectionType) {- case SectionType.SUMMARY:- return `Summary: ${section.summary?.content || "N/A"}`;- case SectionType.EXPERIENCE:- return formatWorkExperiences(section.workExperiences);- case SectionType.EDUCATION:- return formatEducation(section.educations);- default:- return "";- }- })- .join("\n");- };-- const inputMessage = `-- Title: ${resume.title}- ${formatContactInfo(resume.ContactInfo)}- ${formatResumeSections(resume.ResumeSections)}- `;- return inputMessage;+ Please analyze the following resume and job description.++ Resume:+ """+ {resume}+ """++ Job Description:+ """+ {job_description}+ """+ `,+ ],+ ]);++ const inputMessage = await prompt.format({+ resume: resumeText,+ job_description: jobText,+ });+ const model = new ChatOllama({+ baseUrl: process.env.OLLAMA_BASE_URL || "http://127.0.0.1:11434",+ model: "llama3.1",+ temperature: 0,+ format: "json",+ });++ const stream = await model+ .pipe(new StringOutputParser())+ .stream(inputMessage);+ const encoder = new TextEncoder();++ return new ReadableStream({+ async start(controller) {+ for await (const chunk of stream) {+ controller.enqueue(encoder.encode(chunk));+ }+ controller.close();+ },+ });};diff --git a/src/actions/profile.actions.ts b/src/actions/profile.actions.tsindex c321aaf..3efb1d1 100644--- a/src/actions/profile.actions.ts+++ b/src/actions/profile.actions.ts@@ -17,7 +17,6 @@ export const getResumeList = async (): Promise<any | undefined> => {try {const user = await getCurrentUser();-if (!user) {throw new Error("Not authenticated");}diff --git a/src/app/api/ai/resume/match/route.ts b/src/app/api/ai/resume/match/route.tsnew file mode 100644index 0000000..bd432de--- /dev/null+++ b/src/app/api/ai/resume/match/route.ts@@ -0,0 +1,56 @@+import "server-only";++import { auth } from "@/auth";+import { NextApiRequest, NextApiResponse } from "next";+import { NextRequest, NextResponse } from "next/server";+import { Resume } from "@/models/profile.model";+import { getJobMatchByAi } from "@/actions/ai.actions";+import { getResumeById } from "@/actions/profile.actions";+import { getJobDetails } from "@/actions/job.actions";++export const POST = async (req: NextRequest, res: NextApiResponse) => {+ const session = await auth();+ const userId = session?.accessToken.sub;++ if (!session || !session.user) {+ return res.status(401).json({ message: "Not Authenticated" });+ }+ try {+ if (!req.body) {+ throw new Error("Resume and Job Id is required");+ }+ const { resumeId, jobId } = await req.json();++ const [resume, { job }] = await Promise.all([+ getResumeById(resumeId),+ getJobDetails(jobId),+ ]);++ const response = await getJobMatchByAi(resume, job);++ return new NextResponse(response, {+ headers: {+ "Content-Type": "text/event-stream",+ "Cache-Control": "no-cache",+ Connection: "keep-alive",+ },+ });+ } catch (error) {+ const message = "Error getting AI response.";+ console.error(message, error);+ if (error instanceof Error) {+ if (error.message === "fetch failed") {+ error.message =+ "Fetch failed, please make sure selected AI provider service is running.";+ }+ return NextResponse.json(+ { error: error.message },+ { status: 500, statusText: error.message }+ );+ }+ return NextResponse.json(+ { error: message },+ { status: 500, statusText: message }+ );+ }+};diff --git a/src/app/api/ai/route.ts b/src/app/api/ai/resume/review/route.tssimilarity index 100%rename from src/app/api/ai/route.tsrename to src/app/api/ai/resume/review/route.tsdiff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsxindex 6c18473..3aa811e 100644--- a/src/components/myjobs/JobDetails.tsx+++ b/src/components/myjobs/JobDetails.tsx@@ -12,17 +12,37 @@ import {CardTitle,} from "../ui/card";import { Button } from "../ui/button";-import { ArrowLeft } from "lucide-react";+import { ArrowLeft, Sparkles } from "lucide-react";import { useRouter } from "next/navigation";+import { AiJobMatchSection } from "../profile/AiJobMatchSection";+import { useState } from "react";function JobDetails({ job }: { job: JobResponse }) {+ const [aiSectionOpen, setAiSectionOpen] = useState(false);const router = useRouter();const goBack = () => router.back();+ const getAiJobMatch = async () => {+ setAiSectionOpen(true);+ };return (<>- <Button title="Go Back" size="sm" variant="outline" onClick={goBack}>- <ArrowLeft />- </Button>+ <div className="flex justify-between">+ <Button title="Go Back" size="sm" variant="outline" onClick={goBack}>+ <ArrowLeft />+ </Button>+ <Button+ size="sm"+ variant="outline"+ className="h-8 gap-1 cursor-pointer"+ onClick={getAiJobMatch}+ // disabled={loading}+ >+ <Sparkles className="h-3.5 w-3.5" />+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">+ Match with AI+ </span>+ </Button>+ </div>{job?.id && (<Card className="col-span-3"><CardHeader>@@ -68,6 +88,13 @@ function JobDetails({ job }: { job: JobResponse }) {<CardFooter></CardFooter></Card>)}+ {+ <AiJobMatchSection+ jobId={job?.id}+ aISectionOpen={aiSectionOpen}+ triggerChange={setAiSectionOpen}+ />+ }</>);}diff --git a/src/components/profile/AiJobMatchResponseContent.tsx b/src/components/profile/AiJobMatchResponseContent.tsxnew file mode 100644index 0000000..2840411--- /dev/null+++ b/src/components/profile/AiJobMatchResponseContent.tsx@@ -0,0 +1,70 @@+import { SheetDescription } from "../ui/sheet";+import { parse } from "best-effort-json-parser";++export const AiJobMatchResponseContent = ({ content }: { content: any }) => {+ return (+ <>+ <div className="pt-2">+ {content.length > 1 && parse(content).matching_score && (+ <h2>Score: {parse(content).matching_score}</h2>+ )}+ </div>+ <div className="pt-2">+ {content.length > 1 && parse(content).detailed_analysis && (+ <>+ <h2 className="font-semibold">Detailed Analysis:</h2>+ {parse(content).detailed_analysis.map(+ (analysis: any, i: number) => (+ <div key={i}>+ <h2 className="text-white font-medium">+ {analysis.toString().length > 1 && analysis.category}+ </h2>+ <SheetDescription>+ {analysis.value &&+ analysis.value.map((v: string, j: number) => {+ return <li key={j}>{v}</li>;+ })}+ </SheetDescription>+ </div>+ )+ )}+ </>+ )}+ </div>+ <div className="pt-2">+ {content.length > 1 && parse(content).suggestions && (+ <>+ <h2 className="font-semibold">Suggestions: </h2>+ {parse(content).suggestions.map((analysis: any, i: number) => (+ <div key={i}>+ <h2 className="text-white font-medium">+ {analysis.toString().length > 1 && analysis.category}+ </h2>+ <SheetDescription>+ {analysis.value &&+ analysis.value.map((v: string, j: number) => {+ return <li key={j}>{v}</li>;+ })}+ </SheetDescription>+ </div>+ ))}+ </>+ )}+ </div>+ <div className="pt-2">+ {content.length > 1 && parse(content).additional_comments && (+ <>+ <h2 className="font-semibold">Additional Comments: </h2>+ <SheetDescription>+ {parse(content).additional_comments.map(+ (c: string, i: number) => {+ return <li key={i}>{c}</li>;+ }+ )}+ </SheetDescription>+ </>+ )}+ </div>+ </>+ );+};diff --git a/src/components/profile/AiJobMatchSection.tsx b/src/components/profile/AiJobMatchSection.tsxnew file mode 100644index 0000000..4727b5a--- /dev/null+++ b/src/components/profile/AiJobMatchSection.tsx@@ -0,0 +1,167 @@+"use client";+import { getResumeList } from "@/actions/profile.actions";+import {+ Sheet,+ SheetContent,+ SheetHeader,+ SheetPortal,+ SheetTitle,+ SheetTrigger,+} from "../ui/sheet";+import { useEffect, useRef, useState } from "react";+import { Resume } from "@/models/profile.model";+import { toast } from "../ui/use-toast";+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "../ui/select";+import Loading from "../Loading";+import { JobMatchResponse } from "@/models/ai.model";+import { AiJobMatchResponseContent } from "./AiJobMatchResponseContent";++interface AiSectionProps {+ aISectionOpen: boolean;+ triggerChange: (openState: boolean) => void;+ jobId: string;+}++export const AiJobMatchSection = ({+ aISectionOpen,+ triggerChange,+ jobId,+}: AiSectionProps) => {+ const [aIContent, setAIContent] = useState<JobMatchResponse | any>("");+ const [loading, setLoading] = useState(false);++ const resumesRef = useRef<Resume[]>([]);+ const getResumes = async () => {+ try {+ const { data, total, success, message } = await getResumeList();+ if (!data || data.ResumeSections?.length === 0) {+ throw new Error("Resume content is required");+ }+ resumesRef.current = data;+ if (!success) {+ setLoading(false);+ throw new Error(message);+ }+ } catch (error) {+ const message = "Error fetching resume list";+ const description = error instanceof Error ? error.message : message;+ setLoading(false);+ toast({+ variant: "destructive",+ title: "Error!",+ description,+ });+ }+ };+ const readerRef = useRef<ReadableStreamDefaultReader<Uint8Array> | null>(+ null+ );+ const abortControllerRef = useRef<AbortController | null>(null);++ const getJobMatch = async (resumeId: string, jobId: string) => {+ try {+ setLoading(true);+ setAIContent("");+ const abortController = new AbortController();+ abortControllerRef.current = abortController;++ const response = await fetch("/api/ai/resume/match", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ resumeId, jobId }),+ signal: abortController.signal,+ });++ if (!response.body) {+ setLoading(false);+ throw new Error("No response body");+ }++ if (!response.ok) {+ setLoading(false);+ throw new Error(response.statusText);+ }++ const reader = response.body.getReader();+ readerRef.current = reader;+ const decoder = new TextDecoder();+ let done = false;+ setLoading(false);++ while (!done && !abortController.signal.aborted) {+ const { value, done: doneReading } = await reader.read();++ done = doneReading;+ const chunk = decoder.decode(value, { stream: !done });+ const parsedChunk = JSON.parse(JSON.stringify(chunk));+ setAIContent((prev: any) => prev + parsedChunk);+ }+ reader.releaseLock();+ } catch (error) {+ const message = "Error fetching job matching response";+ const description = error instanceof Error ? error.message : message;+ setLoading(false);+ toast({+ variant: "destructive",+ title: "Error!",+ description,+ });+ }+ };+ const onSelectResume = async (resumeId: string) => {+ await getJobMatch(resumeId, jobId);+ };+ useEffect(() => {+ getResumes();+ }, []);+ return (+ <Sheet open={aISectionOpen} onOpenChange={triggerChange}>+ <SheetPortal>+ <SheetContent className="overflow-y-scroll">+ <SheetHeader>+ <SheetTitle>AI Job Match</SheetTitle>+ </SheetHeader>+ <div className="mt-6">+ <Select onValueChange={onSelectResume}>+ <SelectTrigger className="w-[180px]">+ <SelectValue placeholder="Select a resume" />+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ {resumesRef.current.map((resume) => (+ <SelectItem+ key={resume.id}+ value={resume.id!}+ className="capitalize"+ >+ {resume.title}+ </SelectItem>+ ))}+ </SelectGroup>+ </SelectContent>+ </Select>+ </div>+ <div className="mt-6">+ {loading ? (+ <div className="flex items-center flex-col">+ <Loading />+ <div>Loading...</div>+ </div>+ ) : (+ <>+ <AiJobMatchResponseContent content={aIContent} />+ </>+ )}+ </div>+ </SheetContent>+ </SheetPortal>+ </Sheet>+ );+};diff --git a/src/components/AiResponseContent.tsx b/src/components/profile/AiResumeReviewResponseContent.tsxsimilarity index 93%rename from src/components/AiResponseContent.tsxrename to src/components/profile/AiResumeReviewResponseContent.tsxindex c2579a5..3fcc14d 100644--- a/src/components/AiResponseContent.tsx+++ b/src/components/profile/AiResumeReviewResponseContent.tsx@@ -1,7 +1,11 @@-import { SheetDescription } from "./ui/sheet";+import { SheetDescription } from "../ui/sheet";import { parse } from "best-effort-json-parser";-export const AiResponseContent = ({ content }: { content: any }) => {+export const AiResumeReviewResponseContent = ({+ content,+}: {+ content: any;+}) => {return (<><div className="pt-2">diff --git a/src/components/AiSection.tsx b/src/components/profile/AiResumeReviewSection.tsxsimilarity index 89%rename from src/components/AiSection.tsxrename to src/components/profile/AiResumeReviewSection.tsxindex bdc3773..404b365 100644--- a/src/components/AiSection.tsx+++ b/src/components/profile/AiResumeReviewSection.tsx@@ -1,6 +1,6 @@"use client";import { Sparkles } from "lucide-react";-import { Button } from "./ui/button";+import { Button } from "../ui/button";import {Sheet,SheetContent,@@ -9,19 +9,19 @@ import {SheetPortal,SheetTitle,SheetTrigger,-} from "./ui/sheet";-import Loading from "./Loading";+} from "../ui/sheet";+import Loading from "../Loading";import { useRef, useState } from "react";-import { toast } from "./ui/use-toast";+import { toast } from "../ui/use-toast";import { Resume } from "@/models/profile.model";import { ResumeReviewResponse } from "@/models/ai.model";-import { AiResponseContent } from "./AiResponseContent";+import { AiResumeReviewResponseContent } from "./AiResumeReviewResponseContent";interface AiSectionProps {resume: Resume;}-const AiSection = ({ resume }: AiSectionProps) => {+const AiResumeReviewSection = ({ resume }: AiSectionProps) => {const [aIContent, setAIContent] = useState<ResumeReviewResponse | any>("");const [aISectionOpen, setAiSectionOpen] = useState(false);const [loading, setLoading] = useState(false);@@ -41,7 +41,7 @@ const AiSection = ({ resume }: AiSectionProps) => {setAIContent("");const abortController = new AbortController();abortControllerRef.current = abortController;- const response = await fetch("/api/ai", {+ const response = await fetch("/api/ai/resume/review", {method: "POST",headers: { "Content-Type": "application/json" },body: JSON.stringify(resume),@@ -96,7 +96,6 @@ const AiSection = ({ resume }: AiSectionProps) => {abortControllerRef.current?.abort();if (readerRef.current && !readerRef?.current.closed) {await readerRef?.current.cancel();- console.log("closed reader", aIContent);}};@@ -129,7 +128,7 @@ const AiSection = ({ resume }: AiSectionProps) => {<div>Loading...</div></div>) : (- <AiResponseContent content={aIContent} />+ <AiResumeReviewResponseContent content={aIContent} />)}</SheetHeader></SheetContent>@@ -139,4 +138,4 @@ const AiSection = ({ resume }: AiSectionProps) => {);};-export default AiSection;+export default AiResumeReviewSection;diff --git a/src/components/profile/ProfileContainer.tsx b/src/components/profile/ProfileContainer.tsxindex 8c278d1..383948d 100644--- a/src/components/profile/ProfileContainer.tsx+++ b/src/components/profile/ProfileContainer.tsx@@ -8,6 +8,7 @@ import { useSearchParams } from "next/navigation";import { APP_CONSTANTS } from "@/lib/constants";import Loading from "../Loading";import ResumeTable from "./ResumeTable";+import { toast } from "../ui/use-toast";function ActivitiesContainer() {const queryParams = useSearchParams();@@ -26,14 +27,21 @@ function ActivitiesContainer() {const loadResumes = useCallback(async (page: number) => {setLoading(true);- const { data, total, success } = await getResumeList(+ const { data, total, success, message } = await getResumeList(page,recordsPerPage);- setResumes(data);- setTotalResumes(total);if (success) {+ setResumes(data);+ setTotalResumes(total);setLoading(false);+ } else {+ setLoading(false);+ return toast({+ variant: "destructive",+ title: "Error!",+ description: message,+ });}},[recordsPerPage]diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsxindex 5bb886b..b0da211 100644--- a/src/components/profile/ResumeContainer.tsx+++ b/src/components/profile/ResumeContainer.tsx@@ -7,7 +7,7 @@ import { useRef } from "react";import SummarySectionCard from "./SummarySectionCard";import ExperienceCard from "./ExperienceCard";import EducationCard from "./EducationCard";-import AiSection from "../AiSection";+import AiResumeReviewSection from "./AiResumeReviewSection";function ResumeContainer({ resume }: { resume: Resume }) {const resumeSectionRef = useRef<AddResumeSectionRef>(null);@@ -55,7 +55,7 @@ function ResumeContainer({ resume }: { resume: Resume }) {<CardDescription>{title}</CardDescription><div className="flex items-center"><AddResumeSection resume={resume} ref={resumeSectionRef} />- <AiSection resume={resume} />+ <AiResumeReviewSection resume={resume} /></div></CardHeader></Card>diff --git a/src/models/ai.model.ts b/src/models/ai.model.tsindex ea2bb4d..e0c5b3a 100644--- a/src/models/ai.model.ts+++ b/src/models/ai.model.ts@@ -5,3 +5,14 @@ export interface ResumeReviewResponse {suggestions: string[];score: number;}+export interface JobMatchResponse {+ matching_score: number;+ detailed_analysis: JobMatchAnalysis[];+ suggestions: JobMatchAnalysis[];+ additional_comments: string[];+}++export type JobMatchAnalysis = {+ category: string;+ value: string[];+};diff --git a/src/utils/ai.utils.ts b/src/utils/ai.utils.tsnew file mode 100644index 0000000..c20c51d--- /dev/null+++ b/src/utils/ai.utils.ts@@ -0,0 +1,115 @@+import { JobResponse } from "@/models/job.model";+import {+ ContactInfo,+ Education,+ Resume,+ ResumeSection,+ SectionType,+ WorkExperience,+} from "@/models/profile.model";++export const convertResumeToText = (resume: Resume): Promise<string> => {+ return new Promise((resolve) => {+ const formatContactInfo = (contactInfo?: ContactInfo) => {+ if (!contactInfo) return "";+ return `+ Name: ${contactInfo.firstName} ${contactInfo.lastName}+ Headline: ${contactInfo.headline}+ Email: ${contactInfo.email || "N/A"}+ Phone: ${contactInfo.phone || "N/A"}+ Address: ${contactInfo.address || "N/A"}+ `;+ };++ const formatWorkExperiences = (workExperiences?: WorkExperience[]) => {+ if (!workExperiences || workExperiences.length === 0) return "";+ return workExperiences+ .map(+ (experience) => `+ Company: ${experience.Company.label}+ Job Title: ${experience.jobTitle.label}+ Location: ${experience.location.label}+ Description: ${experience.description}+ `+ )+ .join("\n");+ };+ // Start Date: ${experience.startDate.toLocaleDateString().split("T")[0]}+ // End Date: ${+ // experience.currentJob+ // ? "Present"+ // : experience.endDate.toLocaleDateString().split("T")[0]+ // }++ const formatEducation = (educations?: Education[]) => {+ if (!educations || educations.length === 0) return "";+ return (+ educations+ .map(+ (education) => `+ Institution: ${education.institution}+ Degree: ${education.degree}+ Field of Study: ${education.fieldOfStudy}+ Location: ${education.location}+ Description: ${education.description || "N/A"}+ `+ )+ // Start Date: ${education.startDate.toLocaleDateString().split("T")[0]}+ // End Date: ${+ // education.endDate+ // ? education.endDate.toLocaleDateString().split("T")[0]+ // : "N/A"+ // }+ .join("\n")+ );+ };++ const formatResumeSections = (sections?: ResumeSection[]) => {+ if (!sections || sections.length === 0) return "";+ return sections+ .map((section) => {+ switch (section.sectionType) {+ case SectionType.SUMMARY:+ return `Summary: ${section.summary?.content || "N/A"}`;+ case SectionType.EXPERIENCE:+ return formatWorkExperiences(section.workExperiences);+ case SectionType.EDUCATION:+ return formatEducation(section.educations);+ default:+ return "";+ }+ })+ .join("\n");+ };++ const inputMessage = `++ Title: ${resume.title}+ ${formatContactInfo(resume.ContactInfo)}+ ${formatResumeSections(resume.ResumeSections)}+ `;+ return resolve(inputMessage);+ });+};++export const convertJobToText = (job: JobResponse): Promise<string> => {+ return new Promise((resolve) => {+ const {+ description,+ JobTitle: { label: jobTitle },+ Company: { label: companyName },+ Location: { label: location },+ } = job;+ // Remove HTML tags from the description+ const plainDescription = description.replace(/<[^>]+>/g, "");++ const jobText = `+ Job Title: ${jobTitle}+ Company: ${companyName}+ Location: ${location}+ Description: ${plainDescription}+ `;++ return resolve(jobText);+ });+};