File size: 536 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"use client";

import { useState } from "react";
import * as ai from "../services/ai/client";

export default function useAI(){

    const [loading,setLoading]=useState(false);

    async function ask(prompt,projectId){
        setLoading(true);
        try{
            return await ai.sendPrompt(prompt,projectId);
        }finally{
            setLoading(false);
        }
    }

    return {
        loading,
        ask,
        generateCode:ai.generateCode,
        explainCode:ai.explainCode,
        fixCode:ai.fixCode
    };
}