(instructions: string)
| 330 | }; |
| 331 | |
| 332 | const handleModify = async (instructions: string) => { |
| 333 | if (isExampleRepo(repo)) { |
| 334 | setError("Example repositories cannot be modified."); |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | setLoading(true); |
| 339 | setError(""); |
| 340 | setCost(""); |
| 341 | try { |
| 342 | const storedApiKey = localStorage.getItem("openai_key"); |
| 343 | |
| 344 | // Check for API key before proceeding |
| 345 | if (!storedApiKey) { |
| 346 | setError( |
| 347 | "An OpenAI API key is required to generate diagrams. Please provide your API key to continue.", |
| 348 | ); |
| 349 | setState({ status: "error", error: "API key required" }); |
| 350 | setLoading(false); |
| 351 | return; |
| 352 | } |
| 353 | |
| 354 | // Start streaming generation with instructions |
| 355 | await generateDiagram(instructions); |
| 356 | } catch (error) { |
| 357 | console.error("Error modifying diagram:", error); |
| 358 | setError("Failed to modify diagram. Please try again later."); |
| 359 | } finally { |
| 360 | setLoading(false); |
| 361 | } |
| 362 | }; |
| 363 | |
| 364 | const handleRegenerate = async (instructions: string) => { |
| 365 | if (isExampleRepo(repo)) { |
nothing calls this directly
no test coverage detected