add markdown formatting to the AI's responses for the chat page
This commit is contained in:
@@ -6,8 +6,10 @@ const Stripe = require("stripe");
|
||||
|
||||
// Set global options for all functions to use us-central1 region
|
||||
|
||||
const serviceAccount = require("./auditly-consulting-firebase-adminsdk-fbsvc-e4b51ef5cf.json");
|
||||
// const serviceAccount = require("./auditly-c0027-firebase-adminsdk-fbsvc-1db7c58141.json")
|
||||
setGlobalOptions({ region: "us-central1" });
|
||||
|
||||
// const serviceAccount = require("./auditly-consulting-firebase-adminsdk-fbsvc-e4b51ef5cf.json");
|
||||
const serviceAccount = require("./auditly-c0027-firebase-adminsdk-fbsvc-1db7c58141.json")
|
||||
|
||||
admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount)
|
||||
@@ -19,7 +21,7 @@ const db = admin.firestore();
|
||||
// Initialize Vertex AI with your project ID
|
||||
// This automatically uses IAM authentication from the service account
|
||||
const vertexAI = new VertexAI({
|
||||
project: 'auditly-consulting', // Using the project ID from the service account
|
||||
project: 'auditly-c0027', // Using the project ID from the service account
|
||||
location: 'us-central1'
|
||||
});
|
||||
|
||||
@@ -327,7 +329,14 @@ const RESPONSE_FORMAT_COMPANY = {
|
||||
title: { type: "string" },
|
||||
details: {
|
||||
type: "array",
|
||||
items: { type: "string" }
|
||||
items: { type: "string" },
|
||||
description: "Do not include the detail's index in the operating plan, instead, just provide the details",
|
||||
example: [
|
||||
"Implement Comprehensive Data Collection: Immediately deploy a mandatory, company-wide survey to ALL employees (not just one). Ensure robust data collection for all 'Company Context' fields currently marked 'test'. Establish ongoing feedback loops.",
|
||||
"Define Core Strategy: Conduct intensive leadership workshops to articulate and formalize the company's Mission, Vision, Strategic Advantages, and Unique Offering. These must be concrete, measurable, and communicated company-wide.",
|
||||
"Map Current State Operations: Document existing business systems, workflows, and processes. Identify personal dependencies, operational friction points, fragile processes, and recurring problems. This requires direct observation and interviews, not just surveys.",
|
||||
"Financial Health Assessment: Engage an external financial consultant if internal expertise is lacking to establish clear financial reporting, analyze revenue pipeline, customer acquisition costs, LTV, burn rate, and profit margins. No more 'test' financials."
|
||||
]
|
||||
}
|
||||
},
|
||||
required: ["title", "details"]
|
||||
@@ -507,7 +516,11 @@ async function generateWithGemini(prompt, responseFormat = null) {
|
||||
});
|
||||
|
||||
const response = result.response;
|
||||
let content = response.text();
|
||||
let responseContent = "";
|
||||
for (const candidate of response.candidates[0].content.parts) {
|
||||
responseContent += candidate.text;
|
||||
}
|
||||
let content = responseContent;
|
||||
|
||||
// Clean up the response if it has markdown formatting
|
||||
if (content.includes('```json')) {
|
||||
@@ -1654,7 +1667,8 @@ exports.chat = onRequest({cors: true}, async (req, res) => {
|
||||
|
||||
try {
|
||||
// Use Gemini for chat responses
|
||||
const systemPrompt = `You are a cut-and-dry expert business analyst.
|
||||
const systemPrompt = `You should not reference whatever the user has just said. Instead, be direct and find an answer to their question and, when applicable, advise them on what should be done next or ideas for topics of interest that could be explored.
|
||||
You are a cut-and-dry expert business analyst.
|
||||
You provide thoughtful, professional advice based on the employee context and company data provided.
|
||||
|
||||
${context ? `
|
||||
|
||||
Reference in New Issue
Block a user