Skip to content

Commit

Permalink
refactor: Update AI chat handler module, safety settings, and environ…
Browse files Browse the repository at this point in the history
…ment variables
  • Loading branch information
xuelink committed May 26, 2024
1 parent 813f114 commit baeeda1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
9 changes: 1 addition & 8 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
DISCORD_BOT_TOKEN=your_discord_token
DISCORD_CLIENT_ID=your_discord_client_id
GEMINI_API_KEY=your_gemini_api_key

# Example SYSTEM_INSTRUCTION: "You are a helpful assistant."
SYSTEM_INSTRUCTION=your_system_instruction

# Example CHAT_HISTORY:
# [{"role":"user","parts":[{"text":"Oh, thanks! Yes, I am relaxing at home. What about you? Do you have any plans for today?\n"}]},{"role":"model","parts":[{"text":"{\"correction\":null,\"explanation\":null}"}]}]
CHAT_HISTORY=your_chat_history
GEMINI_API_KEY=your_gemini_api_key
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,3 @@ dist

# instructions file
/utils/instructions.js

# chatHistory file
/utils/chatHistory.js
8 changes: 1 addition & 7 deletions copilot/aiHandler.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import dotenv from "dotenv";

import { genAI, safetySettings } from "../utils/common.js";

dotenv.config();

const systemInstruction = process.env.SYSTEM_INSTRUCTION;
const chatHistory = JSON.parse(process.env.CHAT_HISTORY);
import { systemInstruction, chatHistory } from "../utils/instructions.js";

const model = genAI.getGenerativeModel({
model: "gemini-1.5-pro-latest",
Expand Down
14 changes: 0 additions & 14 deletions utils/chatHistory.js.sample

This file was deleted.

15 changes: 15 additions & 0 deletions utils/instructions.js.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
export const systemInstruction = `
You are LangX Language Copilot. An introduction to LangX Copilot, an AI-powered tool designed to enhance your language learning experience with personalized feedback and privacy-focused features.
`;

export const chatHistory = [
{
role: "user",
parts: [
{
text: "Oh, thanks! Yes, I am relaxing at home. What about you? Do you have any plans for today?",
},
],
},
{
role: "model",
parts: [{ text: '{"correction":null,"explanation":null}' }],
},
];

0 comments on commit baeeda1

Please sign in to comment.