Skip to content

Commit 59d4612

Browse files
author
benchify
committed
start calling prod API
1 parent acb585d commit 59d4612

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

lib/benchify.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (!BENCHIFY_API_KEY) {
1515
}
1616

1717
// Repair code using Benchify Fixer API
18-
export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Promise<z.infer<typeof benchifyFileSchema>> {
18+
export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Promise<{ repairedFiles: z.infer<typeof benchifyFileSchema>, buildOutput: string }> {
1919
try {
2020
// Simple build command to verify syntax
2121
const buildCmd = "npm run dev";
@@ -28,13 +28,13 @@ export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Pro
2828
});
2929

3030
console.log('Sending request to Benchify:', {
31-
url: `${BENCHIFY_API_URL}/v1/fixer`,
31+
url: `${BENCHIFY_API_URL}/fixer`,
3232
filesCount: files.length,
3333
jobName: requestData.jobName
3434
});
3535

3636
// Send request to Benchify API
37-
const response = await fetch(`${BENCHIFY_API_URL}/v1/fixer`, {
37+
const response = await fetch(`${BENCHIFY_API_URL}/fixer`, {
3838
method: 'POST',
3939
headers: {
4040
'Content-Type': 'application/json',
@@ -74,13 +74,13 @@ export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Pro
7474
const patchResult = applyPatch(file.contents, result.diff);
7575
return {
7676
path: file.path,
77-
contents: typeof patchResult === 'string' ? patchResult : file.contents
77+
content: typeof patchResult === 'string' ? patchResult : file.content
7878
};
7979
}
8080
return file;
8181
});
8282

83-
return repairedFiles;
83+
return { repairedFiles, buildOutput: result.build_output };
8484
} catch (error) {
8585
if (error instanceof Error) {
8686
console.error('Benchify Processing Error:', {

lib/e2b.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
1515
await sandbox.files.write(
1616
files.map(file => ({
1717
path: `/home/user/app/${file.path}`,
18-
data: file.contents
18+
data: file.content
1919
}))
2020
);
2121

@@ -25,7 +25,7 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
2525
const packageJsonFile = files.find(file => file.path === 'package.json');
2626
if (packageJsonFile) {
2727
try {
28-
const packageJson = JSON.parse(packageJsonFile.contents);
28+
const packageJson = JSON.parse(packageJsonFile.content);
2929
const dependencies = packageJson.dependencies || {};
3030
const devDependencies = packageJson.devDependencies || {};
3131

lib/openai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ if (!OPENAI_API_KEY) {
1313
// Schema for a single file
1414
const fileSchema = z.object({
1515
path: z.string(),
16-
contents: z.string()
16+
content: z.string()
1717
});
1818

1919
// Generate a Vue application using AI SDK
2020
export async function generateApp(
2121
description: string,
22-
): Promise<Array<{ path: string; contents: string }>> {
22+
): Promise<Array<{ path: string; content: string }>> {
2323
console.log("Creating app with description: ", description);
2424

2525
try {

lib/prompts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RESPONSE FORMAT:
1919
You must return a valid JSON array of file objects. Each file object must have exactly this structure:
2020
{
2121
"path": "string (relative path to the file)",
22-
"contents": "string (the complete file contents)"
22+
"content": "string (the complete file content)"
2323
}
2424
2525
Do not include any markdown formatting, code blocks, or explanatory text. The response must be pure JSON.`;

lib/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { z } from 'zod';
44
// Benchify API schema - matching the exact format in the API docs
55
export const benchifyFileSchema = z.array(z.object({
66
path: z.string(),
7-
contents: z.string()
7+
content: z.string()
88
}));
99

1010
export const benchifyRequestSchema = z.object({

lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Process } from '@e2b/sdk';
22

33
export interface GeneratedFile {
44
path: string;
5-
contents: string;
5+
content: string;
66
}
77

88
export interface SandboxFile {

0 commit comments

Comments
 (0)