From 79bf33ca1ccd47e3680e912aebe8bcd243578507 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Mon, 2 Oct 2023 15:30:17 +0300 Subject: [PATCH] fix(chat): Include the name and email of the person asking the question in the prompt for context --- lib/embeddings-query.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/embeddings-query.js b/lib/embeddings-query.js index 69fcbfb..8a61771 100644 --- a/lib/embeddings-query.js +++ b/lib/embeddings-query.js @@ -21,7 +21,9 @@ You are an automated system designed to extract and provide information based on const SCHEMA_PROMPT = ` **Input Information:** -- **Question Format:** The query is presented using the JSON schema: \`{"question":"What was the date of our last meeting?"}\` +- **Question Format:** The query is presented using the JSON schema: \`{"name": "John Doe", "email": "john@example.com", "question":"What was the date of our last meeting?"}\` + + - **Question Structure** The question format includes the asked question, and the name and the email address of the user who asked the question, if available. - **Email Context:** We are provided with a series of emails to analyze. @@ -55,6 +57,10 @@ const SCHEMA_PROMPT = ` - On a new line, begin with \`Message-ID:\` and cite the unique Message-ID(s) of the emails you sourced your answer from. 5. Ensure that the Message-ID is never embedded within the main body of your response. 6. Avoid including any additional commentary or annotations. + +**Context**: + +- The current time is '${new Date().toUTCString()}'. `.trim(); const QUESTION_PROMPT = ` @@ -128,10 +134,10 @@ async function embeddingsQuery(apiToken, opts) { while (true) { prompt = `${SCHEMA_PROMPT} -Input: -${JSON.stringify({ question })} +**Input**: +${JSON.stringify({ name: opts?.userData?.name, email: opts?.userData?.email, question })} -Context emails: +**Context emails**: ${promptText} `;