Skip to content

Commit 5ce5fcd

Browse files
committed
finallly!
1 parent b515dcf commit 5ce5fcd

1 file changed

Lines changed: 7 additions & 25 deletions

File tree

app.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,22 @@ async function processInstruction() {
2020
document.getElementById('loading').style.display = 'block';
2121

2222
try {
23-
// Call OpenAI API
24-
const response = await fetch('https://openai-cf.codediffuser.workers.dev/v1/chat/completions', {
23+
// Call the server endpoint
24+
const response = await fetch('http://34.66.224.14:8080/generate', {
2525
method: 'POST',
2626
headers: {
27-
'Content-Type': 'application/json',
28-
'Authorization': `Bearer robopil_codediffuser`
27+
'Content-Type': 'application/json'
2928
},
30-
body: JSON.stringify({
31-
model: "@cf/meta/llama-2-7b-chat-int8",
32-
messages: [{
33-
role: "user",
34-
content: `Based on this instruction: "${instruction}", select the most appropriate 3D shape from these options:
35-
1: Sphere
36-
2: Cube
37-
3: Torus
38-
4: Cylinder
39-
5: Pyramid
40-
41-
Return only a JSON object with a single number: {"selection": number}`
42-
}]
43-
})
29+
body: JSON.stringify({ instruction })
4430
});
4531

4632
const data = await response.json();
4733
if (!response.ok) {
48-
throw new Error(data.error?.message || 'API request failed');
34+
throw new Error(data.error || 'Request failed');
4935
}
5036

51-
const selection = JSON.parse(data.choices[0].message.content).selection;
52-
if (selection >= 1 && selection <= 5) {
53-
visualizePointCloud(POINT_CLOUDS[selection]);
54-
} else {
55-
throw new Error('Invalid selection');
56-
}
37+
// Visualize the point cloud
38+
visualizePointCloud(data.points);
5739
} catch (error) {
5840
console.error('Error:', error);
5941
alert('Error: ' + error.message);

0 commit comments

Comments
 (0)