Lashtw commited on
Commit
1f943fb
·
verified ·
1 Parent(s): f64454d

Upload 10 files

Browse files
Files changed (1) hide show
  1. src/services/gemini.js +4 -46
src/services/gemini.js CHANGED
@@ -5,52 +5,9 @@ import { db } from "./firebase.js";
5
  import { doc, getDoc } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js";
6
 
7
  let apiKey = null;
8
- const MODEL_NAME = "gemini-1.5-flash"; // Use standard model name
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
@@ -58,7 +15,8 @@ export async function initGemini(key) {
58
  async function callGeminiAPI(messages, jsonMode = false) {
59
  if (!apiKey) throw new Error("API Key not set");
60
 
61
- const endpoint = `https://generativelanguage.googleapis.com/v1beta/models/${MODEL_NAME}:generateContent?key=${apiKey}`;
 
62
 
63
  const payload = {
64
  contents: messages,
 
5
  import { doc, getDoc } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js";
6
 
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
 
15
  async function callGeminiAPI(messages, jsonMode = false) {
16
  if (!apiKey) throw new Error("API Key not set");
17
 
18
+ // Use v1 for gemini-pro (most stable)
19
+ const endpoint = `https://generativelanguage.googleapis.com/v1/models/${MODEL_NAME}:generateContent?key=${apiKey}`;
20
 
21
  const payload = {
22
  contents: messages,