Skip to content

Commit

Permalink
fix: The system prompt is improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj-kumar00 committed Aug 27, 2024
1 parent 6482be1 commit 5573d27
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { NextResponse } from "next/server";
import { NextRequest, NextResponse } from "next/server";
import { Pinecone } from "@pinecone-database/pinecone";
import { OpenAI } from "openai";
import { GoogleGenerativeAI } from "@google/generative-ai";

// Defining systemPrompt
const systemPrompt = `
You are Guru Nimbus,
Your intelligent assistant powered by Retrieval-Augmented Generation (RAG). Please provide your query, and GuruNimbus will generate the optimal result based on its extensive knowledge base.
Just generate the top 3 response of the below format, don't add any extra information.
**Format of the Response for every single professor that user asks:**
**Professor:** [Name]
Expand All @@ -20,14 +21,13 @@ Your intelligent assistant powered by Retrieval-Augmented Generation (RAG). Plea
**Star:** ⭐(this is a sample star, render the stars of every professor have.)
*This field shows a star rating for the quality or relevance of the information provided.*
Feel free to ask your question, and GuruNimbus will provide a comprehensive and insightful response!
Be polite, clear, and concise in your responses.
Provide information that is directly useful and easy for students to understand.
`
;
export async function POST(req: { json: () => any; }) {
`;

export async function POST(req: NextRequest) {
const data = await req.json();
const pc = new Pinecone({
apiKey: process.env.PINECONE_API_KEY || '',
Expand All @@ -49,16 +49,15 @@ export async function POST(req: { json: () => any; }) {
vector: embeddings['values'],
includeMetadata: true,
});

let resultString = "\n\nReturned results from vector db {done automatically}";
results.matches.forEach((match) => {
resultString += `\n
Professor: ${match.id}
Review: ${match.metadata?.review}
Subject: ${match.metadata?.subject}
Stars: ${match.metadata?.stars}
\n\n`
;
\n\n`;
});

const lastMessage = data[data.length - 1];
Expand Down Expand Up @@ -94,7 +93,5 @@ export async function POST(req: { json: () => any; }) {
},
});


return new NextResponse(stream);
}

0 comments on commit 5573d27

Please sign in to comment.