From b32f0948c42ff54ffe8f882194597bfb8fa723b3 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Tue, 15 Jul 2025 11:12:30 -0700 Subject: [PATCH] Added ANSWER programmatic info --- frontend/src/components/ResumeChat.tsx | 41 +++++++++++++++++++++----- src/backend/agents/edit_resume.py | 15 +++++++--- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/ResumeChat.tsx b/frontend/src/components/ResumeChat.tsx index c1e3d23..ab67759 100644 --- a/frontend/src/components/ResumeChat.tsx +++ b/frontend/src/components/ResumeChat.tsx @@ -262,6 +262,13 @@ const ResumeChat = forwardRef( try { apiClient.sendMessageStream(chatMessage, { onMessage: (msg: ChatMessage): void => { + if (msg.content.match(/^ANSWER:\s*/)) { + msg.content = msg.content.replace(/^ANSWER:\s*/, ''); + msg.extraContext = { + isAnswer: true, + }; + } + setMessages(prev => { const filtered = prev.filter(m => m.id !== msg.id); return [...filtered, msg] as ChatMessage[]; @@ -285,6 +292,9 @@ const ResumeChat = forwardRef( }, onStreaming: (chunk: ChatMessageStreaming): void => { // console.log("onStreaming:", chunk); + if (chunk.content[0] === 'A') { + chunk.content = chunk.content.replace(/A[^:]*:?/, ''); + } setStreamingMessage({ ...chunk, role: 'assistant', @@ -341,6 +351,15 @@ const ResumeChat = forwardRef( try { const result = await apiClient.getChatMessages(chatSession.id); const chatMessages: ChatMessage[] = result.data; + chatMessages.forEach(msg => { + if (msg.role === 'assistant' && msg.content.match(/^ANSWER:\s*/)) { + msg.content = msg.content.replace(/^ANSWER:\s*/, ''); + msg.extraContext = { + isAnswer: true, + }; + } + }); + setMessages(chatMessages); setProcessingMessage(null); setStreamingMessage(null); @@ -410,14 +429,20 @@ const ResumeChat = forwardRef( )} {message.role === 'assistant' && ( - { - onResumeChange && onResumeChange(content); - }} - sx={{ maxWidth: '100%', boxSizing: 'border-box' }} - /> + <> + {message.extraContext?.isAnswer ? ( + + ) : ( + { + onResumeChange && onResumeChange(content); + }} + sx={{ maxWidth: '100%', boxSizing: 'border-box' }} + /> + )} + )} ))} diff --git a/src/backend/agents/edit_resume.py b/src/backend/agents/edit_resume.py index db46857..77f4b26 100644 --- a/src/backend/agents/edit_resume.py +++ b/src/backend/agents/edit_resume.py @@ -213,6 +213,14 @@ You are a professional copy editor. Your task is to edit and enhance the provide - DO NOT add quantitative claims like "increased by X%", "reduced by X hours", "saved $X", "improved by X%" unless these exact figures are provided - DO NOT estimate, approximate, or infer numerical data +**RESPONSE FORMAT RULES:** +- IF the user asks a question (contains question words like "what", "how", "why", "when", "where", "which", "who" OR ends with "?"), then: + - Start response with exactly "ANSWER: " (including the space) + - Provide only the answer, not the full resume +- IF the user requests edits/changes to the resume, then: + - Return the complete edited resume without any prefix + - Do not include "ANSWER:" anywhere in the response + **Guidelines:** - You are provided the current resume content in the section - Only make edits that are requested by the user @@ -227,14 +235,13 @@ You are a professional copy editor. Your task is to edit and enhance the provide - Example of ACCEPTABLE impact: "Streamlined resume analysis processes and reduced manual review requirements" - Example of UNACCEPTABLE impact: "Streamlined resume analysis processes with a 40% reduction in manual review time" (unless that 40% is stated in the original content) -If the user asks a question about the resume, provide a brief answer based only on the content of the resume or the context provided. +If the user asks a question about the resume, state "ANSWER:" and then provide a brief answer based only on the content of the resume or the context provided. +Start the response with "ANSWER:" if an answer is being rovided and not the full resume. If the user did not ask a question, return the entire resume with the requested edits applied while maintaining the current formatting. """ - logger.info( - f"Generating resume edits for session {session_id} with prompt: {prompt} and context: {extra_context} and tunables: {tunables}" - ) + logger.info(f"Generating edit_resume response to: {prompt}\ncontext: {extra_context}") async for message in self.edit_resume( llm=llm, model=model,