Spaces:
Running
Running
Update index.html
Browse files- index.html +83 -1
index.html
CHANGED
|
@@ -65,10 +65,36 @@
|
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
async function fetchSlides() {
|
| 73 |
try {
|
| 74 |
const response = await fetch('slide_config.json');
|
|
@@ -86,7 +112,7 @@
|
|
| 86 |
slideTitle.textContent = slide.id.replace('_', ' ');
|
| 87 |
slideImage.src = slide.image;
|
| 88 |
|
| 89 |
-
// Clear prompt and Grok
|
| 90 |
promptBox.style.display = 'none';
|
| 91 |
responseBox.style.display = 'none';
|
| 92 |
responseContent.innerHTML = '';
|
|
@@ -106,7 +132,9 @@
|
|
| 106 |
});
|
| 107 |
|
| 108 |
promptIcon.addEventListener('click', () => {
|
|
|
|
| 109 |
promptBox.style.display = promptBox.style.display === 'block' ? 'none' : 'block';
|
|
|
|
| 110 |
});
|
| 111 |
|
| 112 |
videoIcon.addEventListener('click', () => {
|
|
@@ -122,6 +150,60 @@
|
|
| 122 |
videoPlayer.src = '';
|
| 123 |
});
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
fetchSlides();
|
| 126 |
</script>
|
| 127 |
</body>
|
|
|
|
| 65 |
const videoOverlay = document.getElementById('videoOverlay');
|
| 66 |
const videoPlayer = document.getElementById('videoPlayer');
|
| 67 |
const closeVideo = document.getElementById('closeVideo');
|
| 68 |
+
const queryButton = document.getElementById('queryButton');
|
| 69 |
|
| 70 |
let slides = [];
|
| 71 |
let currentIndex = 0;
|
| 72 |
|
| 73 |
+
// Define agentic workers
|
| 74 |
+
const agents = [
|
| 75 |
+
{
|
| 76 |
+
name: "Zoe Kim",
|
| 77 |
+
systemMessage: `
|
| 78 |
+
You are Zoe Kim, a Software Engineer specializing in full-stack development.
|
| 79 |
+
Discuss application development requirements in 1-2 sentences.
|
| 80 |
+
`,
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
name: "Alex Patel",
|
| 84 |
+
systemMessage: `
|
| 85 |
+
You are Alex Patel, a DevOps Engineer focusing on CI/CD pipelines.
|
| 86 |
+
Respond to Zoe’s suggestions in 1-2 sentences and discuss infrastructure adjustments.
|
| 87 |
+
`,
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
name: "Jack Dawson",
|
| 91 |
+
systemMessage: `
|
| 92 |
+
You are Jack Dawson, a QA and SRE specializing in system reliability.
|
| 93 |
+
Provide concise feedback on Alex’s design in 1-2 sentences, addressing risks or gaps.
|
| 94 |
+
`,
|
| 95 |
+
},
|
| 96 |
+
];
|
| 97 |
+
|
| 98 |
async function fetchSlides() {
|
| 99 |
try {
|
| 100 |
const response = await fetch('slide_config.json');
|
|
|
|
| 112 |
slideTitle.textContent = slide.id.replace('_', ' ');
|
| 113 |
slideImage.src = slide.image;
|
| 114 |
|
| 115 |
+
// Clear prompt and Grok info
|
| 116 |
promptBox.style.display = 'none';
|
| 117 |
responseBox.style.display = 'none';
|
| 118 |
responseContent.innerHTML = '';
|
|
|
|
| 132 |
});
|
| 133 |
|
| 134 |
promptIcon.addEventListener('click', () => {
|
| 135 |
+
const slideText = slides[currentIndex]?.text || "No prompt text available.";
|
| 136 |
promptBox.style.display = promptBox.style.display === 'block' ? 'none' : 'block';
|
| 137 |
+
promptText.value = slideText; // Set prompt text from the slide config
|
| 138 |
});
|
| 139 |
|
| 140 |
videoIcon.addEventListener('click', () => {
|
|
|
|
| 150 |
videoPlayer.src = '';
|
| 151 |
});
|
| 152 |
|
| 153 |
+
queryButton.addEventListener('click', async () => {
|
| 154 |
+
const userPrompt = promptText.value.trim();
|
| 155 |
+
if (!userPrompt) return;
|
| 156 |
+
|
| 157 |
+
responseBox.style.display = "block";
|
| 158 |
+
responseContent.innerHTML = "Loading...";
|
| 159 |
+
|
| 160 |
+
try {
|
| 161 |
+
let conversationLog = [];
|
| 162 |
+
const numIterations = 2; // Number of back-and-forth interactions
|
| 163 |
+
|
| 164 |
+
for (let iteration = 0; iteration < numIterations; iteration++) {
|
| 165 |
+
for (const agent of agents) {
|
| 166 |
+
const response = await fetch(`${BASE_URL}/chat/completions`, {
|
| 167 |
+
method: "POST",
|
| 168 |
+
headers: {
|
| 169 |
+
"Authorization": `Bearer ${API_KEY}`,
|
| 170 |
+
"Content-Type": "application/json"
|
| 171 |
+
},
|
| 172 |
+
body: JSON.stringify({
|
| 173 |
+
model: "grok-beta",
|
| 174 |
+
messages: [
|
| 175 |
+
{ role: "system", content: agent.systemMessage },
|
| 176 |
+
{ role: "user", content: userPrompt },
|
| 177 |
+
...conversationLog.map((log) => ({
|
| 178 |
+
role: "assistant",
|
| 179 |
+
content: log.response,
|
| 180 |
+
})),
|
| 181 |
+
],
|
| 182 |
+
}),
|
| 183 |
+
});
|
| 184 |
+
|
| 185 |
+
if (!response.ok) {
|
| 186 |
+
throw new Error(`Error: ${response.statusText}`);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
const data = await response.json();
|
| 190 |
+
const agentResponse = data.choices?.[0]?.message?.content || "Unexpected API response.";
|
| 191 |
+
conversationLog.push({
|
| 192 |
+
agent: agent.name,
|
| 193 |
+
response: agentResponse,
|
| 194 |
+
});
|
| 195 |
+
|
| 196 |
+
// Append response with styled agent name
|
| 197 |
+
responseContent.innerHTML += `
|
| 198 |
+
<p><span class="agent-name">${agent.name}:</span> ${agentResponse}</p>
|
| 199 |
+
`;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
} catch (error) {
|
| 203 |
+
responseContent.textContent = `Error: ${error.message}`;
|
| 204 |
+
}
|
| 205 |
+
});
|
| 206 |
+
|
| 207 |
fetchSlides();
|
| 208 |
</script>
|
| 209 |
</body>
|