Spaces:
Running
Running
Update index.html
Browse files- index.html +42 -38
index.html
CHANGED
|
@@ -49,22 +49,22 @@
|
|
| 49 |
{
|
| 50 |
name: "Zoe Kim",
|
| 51 |
systemMessage: `
|
| 52 |
-
You are Zoe Kim, a Software Engineer specializing in full-stack development
|
| 53 |
-
|
| 54 |
`,
|
| 55 |
},
|
| 56 |
{
|
| 57 |
name: "Alex Patel",
|
| 58 |
systemMessage: `
|
| 59 |
-
You are Alex Patel, a DevOps Engineer focusing on CI/CD pipelines
|
| 60 |
-
|
| 61 |
`,
|
| 62 |
},
|
| 63 |
{
|
| 64 |
name: "Jack Dawson",
|
| 65 |
systemMessage: `
|
| 66 |
-
You are Jack Dawson, a QA and SRE
|
| 67 |
-
|
| 68 |
`,
|
| 69 |
},
|
| 70 |
];
|
|
@@ -142,39 +142,43 @@
|
|
| 142 |
|
| 143 |
try {
|
| 144 |
let conversationLog = [];
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
role: "
|
| 159 |
-
content:
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
}
|
| 168 |
-
|
| 169 |
-
const data = await response.json();
|
| 170 |
-
const agentResponse = data.choices?.[0]?.message?.content || "Unexpected API response.";
|
| 171 |
-
conversationLog.push({
|
| 172 |
-
agent: agent.name,
|
| 173 |
-
response: agentResponse,
|
| 174 |
-
});
|
| 175 |
-
|
| 176 |
-
// Append response to content
|
| 177 |
-
responseContent.innerHTML += `<strong>${agent.name}:</strong><br>${marked.parse(agentResponse)}<br><hr>`;
|
| 178 |
}
|
| 179 |
} catch (error) {
|
| 180 |
responseContent.textContent = `Error: ${error.message}`;
|
|
|
|
| 49 |
{
|
| 50 |
name: "Zoe Kim",
|
| 51 |
systemMessage: `
|
| 52 |
+
You are Zoe Kim, a Software Engineer specializing in full-stack development.
|
| 53 |
+
Start by discussing the application’s development requirements concisely.
|
| 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, offering infrastructure adjustments.
|
| 61 |
`,
|
| 62 |
},
|
| 63 |
{
|
| 64 |
name: "Jack Dawson",
|
| 65 |
systemMessage: `
|
| 66 |
+
You are Jack Dawson, a QA and SRE ensuring system reliability.
|
| 67 |
+
Provide quick feedback on Alex’s pipeline design, addressing risks or gaps.
|
| 68 |
`,
|
| 69 |
},
|
| 70 |
];
|
|
|
|
| 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><br>${marked.parse(agentResponse)}<br><hr>`;
|
| 181 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
} catch (error) {
|
| 184 |
responseContent.textContent = `Error: ${error.message}`;
|