Spaces:
Running
Running
Upload 10 files
Browse files- src/services/gemini.js +44 -1
src/services/gemini.js
CHANGED
|
@@ -7,7 +7,50 @@ import { doc, getDoc } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-
|
|
| 7 |
let apiKey = null;
|
| 8 |
const MODEL_NAME = "gemini-pro"; // Fallback to stable Pro model
|
| 9 |
|
| 10 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Direct REST API Call Helper to avoid SDK version issues
|
|
|
|
| 7 |
let apiKey = null;
|
| 8 |
const MODEL_NAME = "gemini-pro"; // Fallback to stable Pro model
|
| 9 |
|
| 10 |
+
// System Instructions for the Socratic Tutor
|
| 11 |
+
const TUTOR_INSTRUCTION = `
|
| 12 |
+
You are a Socratic Teaching Assistant for a "Prompt Engineering" class.
|
| 13 |
+
Your goal is to help students refine their prompts WITHOUT giving them the answer.
|
| 14 |
+
The student is trying to write a prompt to solve a specific challenge.
|
| 15 |
+
You will be provided with:
|
| 16 |
+
1. The Challenge Description (The Goal).
|
| 17 |
+
2. 3 Successful Examples (Few-Shot Context) from other students.
|
| 18 |
+
3. The Student's Current Attempt.
|
| 19 |
+
|
| 20 |
+
Rules:
|
| 21 |
+
- NEVER reveal the direct solution or code.
|
| 22 |
+
- If the input is lazy (e.g., "123", "help"), be sassy but helpful.
|
| 23 |
+
- If the input is a direct copy of the description, point it out.
|
| 24 |
+
- Use the Socratic method: Ask a guiding question to help them notice their missing parameter or logic.
|
| 25 |
+
- Keep responses short (under 50 words) and encouraging.
|
| 26 |
+
- Tone: Friendly, slightly "Cyberpunk" or "Gamer" vibe (matching the Vibe Coding aesthetic).
|
| 27 |
+
`;
|
| 28 |
+
|
| 29 |
+
// System Instructions for the Dashboard Analyst
|
| 30 |
+
const ANALYST_INSTRUCTION = `
|
| 31 |
+
You are an expert Prompt Engineer and Pedagogy Analyst.
|
| 32 |
+
Your task is to analyze a batch of student prompts for a specific coding challenge.
|
| 33 |
+
Categorize each prompt into ONE of these categories:
|
| 34 |
+
1. "rough": Logic is correct/creative, but syntax or formatting is messy. (Rough Diamond)
|
| 35 |
+
2. "precise": Clean, efficient, and accurate. (Pixel Perfect)
|
| 36 |
+
3. "gentle": Uses polite language ("Please", "Thank you") or positive vibes. (Gentle Soul)
|
| 37 |
+
4. "creative": Unconventional approach or interesting parameter usage. (Wild Card)
|
| 38 |
+
5. "spam": Nonsense, random characters ("asdf"), or irrelevant text.
|
| 39 |
+
6. "parrot": Direct copy-paste of the challenge description or problem statement.
|
| 40 |
+
|
| 41 |
+
Return ONLY a JSON object mapping category names to arrays of Student IDs.
|
| 42 |
+
Example: { "rough": ["id1"], "precise": ["id2", "id5"], "spam": ["id3"] ... }
|
| 43 |
+
`;
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Initialize Gemini with API Key
|
| 47 |
+
* @param {string} key
|
| 48 |
+
*/
|
| 49 |
+
export async function initGemini(key) {
|
| 50 |
+
if (!key) return false;
|
| 51 |
+
apiKey = key;
|
| 52 |
+
return true;
|
| 53 |
+
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Direct REST API Call Helper to avoid SDK version issues
|