eaglelandsonce commited on
Commit
c8249ee
·
verified ·
1 Parent(s): 8208a5d

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +43 -104
index.html CHANGED
@@ -14,6 +14,10 @@
14
  <img src="prompt-icon.png" alt="Prompt Icon">
15
  <span>Prompt</span>
16
  </div>
 
 
 
 
17
  </div>
18
 
19
  <!-- Main Container -->
@@ -37,43 +41,31 @@
37
  </div>
38
  </div>
39
  </div>
 
 
 
 
40
  </div>
41
 
42
  <script>
43
- // Define the Grok API constants
44
  const BASE_URL = "https://api.x.ai/v1";
45
  const API_KEY = "xai-hOb0j9QUXVVQMe86ULxWrvyWQQm2LqnWVdxh5hanvqsiVDsXcSPY9EA7YAM5uLCXaThgJscWxxFCHJFy";
46
 
47
- // Define agentic workers
48
- const agents = [
49
- {
50
- name: "Zoe Kim",
51
- systemMessage: `
52
- You are Zoe Kim, a Software Engineer specializing in full-stack development.
53
- Keep your response brief (1-2 sentences). Start by discussing the application’s development requirements.
54
- `,
55
- },
56
- {
57
- name: "Alex Patel",
58
- systemMessage: `
59
- You are Alex Patel, a DevOps Engineer focusing on CI/CD pipelines.
60
- Respond briefly to Zoe’s suggestions and discuss infrastructure adjustments in 1-2 sentences.
61
- `,
62
- },
63
- {
64
- name: "Jack Dawson",
65
- systemMessage: `
66
- You are Jack Dawson, a QA and SRE specializing in system reliability.
67
- Provide concise feedback on Alex’s design (1-2 sentences), focusing on risks or gaps.
68
- `,
69
- },
70
- ];
71
-
72
- // Slide viewer script
73
  const slideTitle = document.getElementById('slide-title');
74
  const slideImage = document.getElementById('slide-image');
75
  const prevBtn = document.getElementById('prev-btn');
76
  const nextBtn = document.getElementById('next-btn');
 
 
 
 
 
 
 
 
 
 
77
  let slides = [];
78
  let currentIndex = 0;
79
 
@@ -93,97 +85,44 @@
93
  const slide = slides[index];
94
  slideTitle.textContent = slide.id.replace('_', ' ');
95
  slideImage.src = slide.image;
 
 
 
 
 
 
 
 
96
  }
97
 
98
  prevBtn.addEventListener('click', () => {
99
- if (slides.length > 0) {
100
- currentIndex = (currentIndex - 1 + slides.length) % slides.length;
101
- loadSlide(currentIndex);
102
- }
103
  });
104
 
105
  nextBtn.addEventListener('click', () => {
106
- if (slides.length > 0) {
107
- currentIndex = (currentIndex + 1) % slides.length;
108
- loadSlide(currentIndex);
109
- }
110
  });
111
 
112
- // Initialize slides
113
- fetchSlides();
114
-
115
- // Grok Chat script with agentic workers
116
- const promptIcon = document.getElementById('promptIcon');
117
- const promptBox = document.getElementById('promptBox');
118
- const promptText = document.getElementById('promptText');
119
- const queryButton = document.getElementById('queryButton');
120
- const responseBox = document.getElementById('responseBox');
121
- const responseContent = document.getElementById('responseContent');
122
- let isPromptBoxVisible = false;
123
-
124
  promptIcon.addEventListener('click', () => {
125
- isPromptBoxVisible = !isPromptBoxVisible;
126
- promptBox.style.display = isPromptBoxVisible ? "block" : "none";
127
 
128
- if (isPromptBoxVisible) {
129
- const slideText = slides[currentIndex]?.text || "Default prompt text";
130
- promptText.value = slideText;
131
- } else {
132
- responseBox.style.display = "none";
133
  }
134
  });
135
 
136
- queryButton.addEventListener('click', async () => {
137
- const userPrompt = promptText.value.trim();
138
- if (!userPrompt) return;
139
-
140
- responseBox.style.display = "block";
141
- responseContent.innerHTML = "Loading...";
142
-
143
- try {
144
- let conversationLog = [];
145
- const numIterations = 2; // Number of back-and-forth interactions
146
-
147
- for (let iteration = 0; iteration < numIterations; iteration++) {
148
- for (const agent of agents) {
149
- const response = await fetch(`${BASE_URL}/chat/completions`, {
150
- method: "POST",
151
- headers: {
152
- "Authorization": `Bearer ${API_KEY}`,
153
- "Content-Type": "application/json"
154
- },
155
- body: JSON.stringify({
156
- model: "grok-beta",
157
- messages: [
158
- { role: "system", content: agent.systemMessage },
159
- { role: "user", content: userPrompt },
160
- ...conversationLog.map((log) => ({
161
- role: "assistant",
162
- content: log.response,
163
- })),
164
- ],
165
- }),
166
- });
167
-
168
- if (!response.ok) {
169
- throw new Error(`Error: ${response.statusText}`);
170
- }
171
-
172
- const data = await response.json();
173
- const agentResponse = data.choices?.[0]?.message?.content || "Unexpected API response.";
174
- conversationLog.push({
175
- agent: agent.name,
176
- response: agentResponse,
177
- });
178
-
179
- // Append response to content
180
- responseContent.innerHTML += `<strong>${agent.name}:</strong> ${agentResponse}<br>`;
181
- }
182
- }
183
- } catch (error) {
184
- responseContent.textContent = `Error: ${error.message}`;
185
- }
186
  });
 
 
187
  </script>
188
  </body>
189
  </html>
 
14
  <img src="prompt-icon.png" alt="Prompt Icon">
15
  <span>Prompt</span>
16
  </div>
17
+ <div class="video-icon" id="videoIcon">
18
+ <img src="video-icon.png" alt="Video Icon">
19
+ <span>Video</span>
20
+ </div>
21
  </div>
22
 
23
  <!-- Main Container -->
 
41
  </div>
42
  </div>
43
  </div>
44
+ <div class="video-overlay" id="videoOverlay" style="display: none;">
45
+ <iframe id="videoPlayer" src="" allowfullscreen></iframe>
46
+ <button class="close-button" id="closeVideo">×</button>
47
+ </div>
48
  </div>
49
 
50
  <script>
 
51
  const BASE_URL = "https://api.x.ai/v1";
52
  const API_KEY = "xai-hOb0j9QUXVVQMe86ULxWrvyWQQm2LqnWVdxh5hanvqsiVDsXcSPY9EA7YAM5uLCXaThgJscWxxFCHJFy";
53
 
54
+ // DOM elements
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  const slideTitle = document.getElementById('slide-title');
56
  const slideImage = document.getElementById('slide-image');
57
  const prevBtn = document.getElementById('prev-btn');
58
  const nextBtn = document.getElementById('next-btn');
59
+ const promptBox = document.getElementById('promptBox');
60
+ const promptText = document.getElementById('promptText');
61
+ const responseBox = document.getElementById('responseBox');
62
+ const responseContent = document.getElementById('responseContent');
63
+ const promptIcon = document.getElementById('promptIcon');
64
+ const videoIcon = document.getElementById('videoIcon');
65
+ const videoOverlay = document.getElementById('videoOverlay');
66
+ const videoPlayer = document.getElementById('videoPlayer');
67
+ const closeVideo = document.getElementById('closeVideo');
68
+
69
  let slides = [];
70
  let currentIndex = 0;
71
 
 
85
  const slide = slides[index];
86
  slideTitle.textContent = slide.id.replace('_', ' ');
87
  slideImage.src = slide.image;
88
+
89
+ // Clear prompt and Grok information
90
+ promptBox.style.display = 'none';
91
+ responseBox.style.display = 'none';
92
+ responseContent.innerHTML = '';
93
+
94
+ // Reset video player
95
+ videoPlayer.src = '';
96
  }
97
 
98
  prevBtn.addEventListener('click', () => {
99
+ currentIndex = (currentIndex - 1 + slides.length) % slides.length;
100
+ loadSlide(currentIndex);
 
 
101
  });
102
 
103
  nextBtn.addEventListener('click', () => {
104
+ currentIndex = (currentIndex + 1) % slides.length;
105
+ loadSlide(currentIndex);
 
 
106
  });
107
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  promptIcon.addEventListener('click', () => {
109
+ promptBox.style.display = promptBox.style.display === 'block' ? 'none' : 'block';
110
+ });
111
 
112
+ videoIcon.addEventListener('click', () => {
113
+ const videoURL = slides[currentIndex]?.video || '';
114
+ if (videoURL) {
115
+ videoPlayer.src = videoURL;
116
+ videoOverlay.style.display = 'flex';
117
  }
118
  });
119
 
120
+ closeVideo.addEventListener('click', () => {
121
+ videoOverlay.style.display = 'none';
122
+ videoPlayer.src = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  });
124
+
125
+ fetchSlides();
126
  </script>
127
  </body>
128
  </html>