File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ GEMINI_EMBEDDING_MODEL="text-embedding-004"
2020GEMINI_CHAT_MODEL = " gemini-2.0-flash-lite"
2121GEMINI_RAG_TYPE = " advanced" # basic (no RAG) or advanced (RAG)
2222GEMINI_N_RESULTS = " 5" # number of results to use (only used for "advanced" rag type)
23+ GEMINI_SYSTEM_PROMPT = " You are a helpful assistant for React ChatBotify, a React library for building flexible and extensible chatbots."
2324
2425# ChromaDB Configuration
2526CHROMA_URL = " http://chromadb"
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export const config = {
3232
3333 geminiRagType : process . env . GEMINI_RAG_TYPE || 'basic' ,
3434
35+ geminiSystemPrompt :
36+ process . env . GEMINI_SYSTEM_PROMPT ||
37+ 'You are a helpful assistant for React ChatBotify, a React library for building flexible and extensible chatbots.' ,
38+
3539 // Server Configuration
3640 port : process . env . PORT || 8080 ,
3741
Original file line number Diff line number Diff line change @@ -35,7 +35,14 @@ export const generateText = async (
3535
3636 try {
3737 const geminiModelId = model || config . geminiChatModel || 'gemini-pro' ;
38- const geminiContents : GeminiContent [ ] = [ { parts : [ { text : query } ] , role : 'user' } ] ;
38+ let geminiContents : GeminiContent [ ] ;
39+
40+ if ( config . geminiSystemPrompt && config . geminiSystemPrompt . trim ( ) !== '' ) {
41+ geminiContents = [ { parts : [ { text : config . geminiSystemPrompt } ] , role : 'user' } ] ;
42+ geminiContents . push ( { parts : [ { text : query } ] , role : 'user' } ) ;
43+ } else {
44+ geminiContents = [ { parts : [ { text : query } ] , role : 'user' } ] ;
45+ }
3946
4047 if ( stream ) {
4148 if ( ! onChunk ) {
You can’t perform that action at this time.
0 commit comments