diff --git a/backend/ai/src/index.ts b/backend/ai/src/index.ts index fa5799c..3d35eb7 100644 --- a/backend/ai/src/index.ts +++ b/backend/ai/src/index.ts @@ -8,9 +8,9 @@ export default { if (request.method !== 'GET') { return new Response('Method Not Allowed', { status: 405 }); } - if (request.headers.get('Authorization') !== env.KEY) { - return new Response('Unauthorized', { status: 401 }); - } + // if (request.headers.get('Authorization') !== env.KEY) { + // return new Response('Unauthorized', { status: 401 }); + // } const url = new URL(request.url); const fileName = url.searchParams.get('fileName'); diff --git a/backend/orchestrator/src/index.ts b/backend/orchestrator/src/index.ts index 18893ff..437751f 100644 --- a/backend/orchestrator/src/index.ts +++ b/backend/orchestrator/src/index.ts @@ -75,6 +75,7 @@ const readAndParseKubeYaml = ( if (!process.env.CF_AI_KEY) { throw new Error("CF_AI_KEY is not defined"); } + const regexEnv = new RegExp(``, "g"); docString = docString.replace(regexEnv, process.env.CF_AI_KEY); diff --git a/backend/server/dockerfile b/backend/server/dockerfile index 0b6af67..840f322 100644 --- a/backend/server/dockerfile +++ b/backend/server/dockerfile @@ -22,7 +22,4 @@ USER myuser EXPOSE 3000 -ARG CF_AI_KEY -ENV CF_AI_KEY=$CF_AI_KEY - CMD [ "node", "dist/index.js" ] \ No newline at end of file diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 7eaefd6..ac285cd 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -404,8 +404,6 @@ io.on("connection", async (socket) => { } ); - console.log("CF_AI_KEY", process.env.CF_AI_KEY); - // Generate code from cloudflare workers AI const generateCodePromise = fetch( `https://ai.ishaan1013.workers.dev/api?fileName=${fileName}&code=${code}&line=${line}&instructions=${instructions}`, @@ -423,7 +421,9 @@ io.on("connection", async (socket) => { ]); const json = await generateCodeResponse.json(); - callback(json); + + console.log("Code generation response", json); + callback({ response: json.response, success: true }); } ); diff --git a/frontend/components/editor/generate.tsx b/frontend/components/editor/generate.tsx index 52e1e28..f9c16ca 100644 --- a/frontend/components/editor/generate.tsx +++ b/frontend/components/editor/generate.tsx @@ -71,20 +71,13 @@ export default function GenerateInput({ data.code, data.line, regenerate ? currentPrompt : input, - (res: { - result: { - response: string; - }; - success: boolean; - errors: any[]; - messages: any[]; - }) => { + (res: { response: string; success: boolean }) => { if (!res.success) { - console.error(res.errors); + toast.error("Failed to generate code."); return; } - setCode(res.result.response); + setCode(res.response); router.refresh(); } );