Skip to content

Commit b2c76ac

Browse files
committed
chore: Add default system prompt
1 parent bcedb46 commit b2c76ac

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

config/env/.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ GEMINI_EMBEDDING_MODEL="text-embedding-004"
2020
GEMINI_CHAT_MODEL="gemini-2.0-flash-lite"
2121
GEMINI_RAG_TYPE="advanced" # basic (no RAG) or advanced (RAG)
2222
GEMINI_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
2526
CHROMA_URL="http://chromadb"

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/services/llmWrapper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)