MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / handleInput

Function handleInput

client/src/component/AIReview.jsx:12–38  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

10 const [error, setError] = useState("");
11
12 const handleInput = async (type) => {
13 if (!apiKey) {
14 setError("API Key is required");
15 return;
16 }
17
18 setError("");
19 try {
20 const genAI = new GoogleGenerativeAI(apiKey);
21 const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
22
23 if (type === "review") {
24 const prompt =
25 "Review the following code and provide feedback. \n\n" + codeInput;
26
27 const result = await model.generateContent(prompt);
28 setReviewResult(result.response.text());
29 } else if (type === "ideas") {
30 const prompt =
31 "Generate project ideas for a " + projectType + " project.";
32 const result = await model.generateContent(prompt);
33 setIdeaResult(result.response.text());
34 }
35 } catch (err) {
36 setError("An error occurred while processing your request.");
37 }
38 };
39
40 return (
41 <div className="p-6 min-h-screen flex flex-col justify-center text-black overflow-auto main-content">

Callers 1

AiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected