|
36 | 36 | max-height: 80%; |
37 | 37 | overflow: auto; |
38 | 38 | } |
| 39 | + #generating { |
| 40 | + position: absolute; |
| 41 | + top: 50%; |
| 42 | + left: 50%; |
| 43 | + transform: translate(-50%, -50%); |
| 44 | + color: white; |
| 45 | + background-color: rgba(0, 0, 0, 0.7); |
| 46 | + padding: 10px; |
| 47 | + border-radius: 5px; |
| 48 | + display: none; |
| 49 | + font-family:'Courier New', Courier, monospace; |
| 50 | + } |
39 | 51 | </style> |
40 | 52 | </head> |
41 | 53 | <body> |
|
87 | 99 | </button> |
88 | 100 | </div> |
89 | 101 | <pre id="response"></pre> |
| 102 | + <div id="generating">Generating...</div> |
90 | 103 | <script> |
91 | 104 | const video = document.getElementById("video"); |
92 | 105 | video.setAttribute("autoplay", ""); |
|
96 | 109 | const captureBtn = document.getElementById("captureBtn"); |
97 | 110 | switchCameraBtn.style.display = "none"; |
98 | 111 | const responseElement = document.getElementById("response"); |
| 112 | + const generatingElement = document.getElementById("generating"); |
99 | 113 | let currentStream; |
100 | 114 | let currentCamera = "front"; |
101 | 115 |
|
|
181 | 195 | }, |
182 | 196 | ], |
183 | 197 | }; |
184 | | - fetch("https://anthropic-proxy.vercel.app/v1/messages", { |
| 198 | + |
| 199 | + // Show "Generating..." message |
| 200 | + generatingElement.style.display = "block"; |
| 201 | + |
| 202 | + fetch("https://api.anthropic.com/v1/messages", { |
185 | 203 | method: "POST", |
186 | 204 | headers: { |
187 | 205 | "x-api-key": apiKey, |
188 | 206 | "anthropic-version": "2023-06-01", |
189 | 207 | "content-type": "application/json", |
| 208 | + "anthropic-dangerous-direct-browser-access": "true" |
190 | 209 | }, |
191 | 210 | body: JSON.stringify(requestBody), |
192 | 211 | }) |
|
198 | 217 | }) |
199 | 218 | .catch((error) => { |
200 | 219 | console.error("Error sending image to the Anthropic API:", error); |
| 220 | + }) |
| 221 | + .finally(() => { |
| 222 | + // Hide "Generating..." message |
| 223 | + generatingElement.style.display = "none"; |
201 | 224 | }); |
202 | 225 | }); |
203 | 226 | // Start the camera when the page loads |
|
0 commit comments