Mr-67 commited on
Commit
5aa1400
·
verified ·
1 Parent(s): dddc5ea

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +54 -26
index.html CHANGED
@@ -3,23 +3,23 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Browser-Based AI Assistant</title>
7
  <style>
8
  body {
9
  font-family: system-ui, -apple-system, sans-serif;
10
  max-width: 700px;
11
  margin: 2rem auto;
12
  padding: 0 1rem;
13
- background-color: #f9fafb;
14
- color: #111827;
15
  }
16
 
17
  .card {
18
  background: #ffffff;
19
  padding: 1.5rem;
20
- border-radius: 10px;
21
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
22
- border: 1px solid #e5e7eb;
23
  }
24
 
25
  label {
@@ -33,14 +33,20 @@
33
  width: 100%;
34
  padding: 0.75rem;
35
  border-radius: 6px;
36
- border: 1px solid #d1d5db;
37
  box-sizing: border-box;
38
  font-size: 1rem;
39
  }
40
 
 
 
 
 
 
 
41
  button {
42
- margin-top: 1rem;
43
- background-color: #2563eb;
44
  color: white;
45
  font-weight: 600;
46
  border: none;
@@ -48,44 +54,57 @@
48
  }
49
 
50
  button:hover {
51
- background-color: #1d4ed8;
52
  }
53
 
54
  .output-area {
55
- margin-top: 1.5rem;
56
  padding: 1rem;
57
- background-color: #f3f4f6;
58
  border-radius: 6px;
59
  min-height: 80px;
60
  white-space: pre-wrap;
 
61
  }
62
  </style>
63
 
64
- <!-- Load Transformers.js for browser-based AI -->
65
  <script type="module">
66
  import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.0';
67
 
68
  let generator = null;
69
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  window.runAI = async function() {
71
  const task = document.getElementById('taskSelect').value;
72
  const input = document.getElementById('userPrompt').value.trim();
73
  const output = document.getElementById('output');
74
 
75
  if (!input) {
76
- output.textContent = "Please enter some details first.";
77
  return;
78
  }
79
 
80
- output.textContent = "Loading model and generating response... (This may take a moment on first run)";
81
 
82
  try {
83
- // Load a lightweight model that fits into browser memory
84
  if (!generator) {
85
  generator = await pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-77M');
86
  }
87
 
88
- const prompt = `Task: ${task}\nInput: ${input}\nOutput:`;
 
89
  const result = await generator(prompt, {
90
  max_new_tokens: 150,
91
  repetition_penalty: 1.5,
@@ -95,7 +114,7 @@
95
 
96
  output.textContent = result[0].generated_text;
97
  } catch (error) {
98
- output.textContent = "Error generating text: " + error.message;
99
  }
100
  };
101
  </script>
@@ -103,22 +122,31 @@
103
  <body>
104
 
105
  <div class="card">
106
- <h2>Synergy Helper AI</h2>
107
 
108
- <label for="taskSelect">Select Task:</label>
109
  <select id="taskSelect">
110
- <option value="Summarize notes">Summarize Text / Notes</option>
111
- <option value="Format text">Format Assignment Info</option>
112
- <option value="Draft message">Draft Communication</option>
 
 
 
 
 
 
 
 
 
113
  </select>
114
 
115
- <label for="userPrompt">Enter Information:</label>
116
- <textarea id="userPrompt" rows="4" placeholder="Enter your text here..."></textarea>
117
 
118
  <button onclick="runAI()">Generate Response</button>
119
 
120
- <label>AI Output:</label>
121
- <div id="output" class="output-area">Output will appear here...</div>
122
  </div>
123
 
124
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Synergy Teacher Assistant</title>
7
  <style>
8
  body {
9
  font-family: system-ui, -apple-system, sans-serif;
10
  max-width: 700px;
11
  margin: 2rem auto;
12
  padding: 0 1rem;
13
+ background-color: #f8fafc;
14
+ color: #0f172a;
15
  }
16
 
17
  .card {
18
  background: #ffffff;
19
  padding: 1.5rem;
20
+ border-radius: 12px;
21
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
22
+ border: 1px solid #e2e8f0;
23
  }
24
 
25
  label {
 
33
  width: 100%;
34
  padding: 0.75rem;
35
  border-radius: 6px;
36
+ border: 1px solid #cbd5e1;
37
  box-sizing: border-box;
38
  font-size: 1rem;
39
  }
40
 
41
+ textarea {
42
+ resize: vertical;
43
+ min-height: 100px;
44
+ font-family: inherit;
45
+ }
46
+
47
  button {
48
+ margin-top: 1.25rem;
49
+ background-color: #4f46e5;
50
  color: white;
51
  font-weight: 600;
52
  border: none;
 
54
  }
55
 
56
  button:hover {
57
+ background-color: #4338ca;
58
  }
59
 
60
  .output-area {
61
+ margin-top: 1.25rem;
62
  padding: 1rem;
63
+ background-color: #f1f5f9;
64
  border-radius: 6px;
65
  min-height: 80px;
66
  white-space: pre-wrap;
67
+ word-break: break-word;
68
  }
69
  </style>
70
 
 
71
  <script type="module">
72
  import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.0';
73
 
74
  let generator = null;
75
 
76
+ // Fills text box when a pre-made question is clicked
77
+ window.handleQuickSelect = function() {
78
+ const quickSelect = document.getElementById('quickSelect').value;
79
+ const input = document.getElementById('userPrompt');
80
+
81
+ if (quickSelect !== "custom") {
82
+ input.value = quickSelect;
83
+ } else {
84
+ input.value = "";
85
+ }
86
+ };
87
+
88
  window.runAI = async function() {
89
  const task = document.getElementById('taskSelect').value;
90
  const input = document.getElementById('userPrompt').value.trim();
91
  const output = document.getElementById('output');
92
 
93
  if (!input) {
94
+ output.textContent = "Please select or type a question first.";
95
  return;
96
  }
97
 
98
+ output.textContent = "Processing request... (Takes a few seconds)";
99
 
100
  try {
101
+ // Fast, reliable 80MB model for static spaces
102
  if (!generator) {
103
  generator = await pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-77M');
104
  }
105
 
106
+ const prompt = `Task: ${task}. Request: ${input}`;
107
+
108
  const result = await generator(prompt, {
109
  max_new_tokens: 150,
110
  repetition_penalty: 1.5,
 
114
 
115
  output.textContent = result[0].generated_text;
116
  } catch (error) {
117
+ output.textContent = "Error generating response: " + error.message;
118
  }
119
  };
120
  </script>
 
122
  <body>
123
 
124
  <div class="card">
125
+ <h2>Synergy Teacher Helper</h2>
126
 
127
+ <label for="taskSelect">1. Category / Action:</label>
128
  <select id="taskSelect">
129
+ <option value="General Synergy Guide">Synergy How-To / Setup Guide</option>
130
+ <option value="Gradebook Help">Gradebook & Assignments</option>
131
+ <option value="Student Communication">Parent & Student Communication</option>
132
+ </select>
133
+
134
+ <label for="quickSelect">2. Quick Pre-made Questions:</label>
135
+ <select id="quickSelect" onchange="handleQuickSelect()">
136
+ <option value="custom">-- Choose a common question (or write your own below) --</option>
137
+ <option value="How do I create an electronic hall pass system in Synergy?">How do I create an electronic hall pass?</option>
138
+ <option value="How do I post a new assignment to StudentVUE and ParentVUE?">How do I post an assignment to StudentVUE/ParentVUE?</option>
139
+ <option value="How do I write a constructive report card comment for missing work?">How do I write a report comment for missing work?</option>
140
+ <option value="How do I email parents directly from the Synergy gradebook?">How do I email parents from the gradebook?</option>
141
  </select>
142
 
143
+ <label for="userPrompt">3. Details / Custom Question:</label>
144
+ <textarea id="userPrompt" placeholder="Select a pre-made question above or type your own question here..."></textarea>
145
 
146
  <button onclick="runAI()">Generate Response</button>
147
 
148
+ <label>Result:</label>
149
+ <div id="output" class="output-area">Response will appear here...</div>
150
  </div>
151
 
152
  </body>