Skip to content

start calling prod API #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/benchify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (!BENCHIFY_API_KEY) {
}

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

console.log('Sending request to Benchify:', {
url: `${BENCHIFY_API_URL}/v1/fixer`,
url: `${BENCHIFY_API_URL}/fixer`,
filesCount: files.length,
jobName: requestData.jobName
});

// Send request to Benchify API
const response = await fetch(`${BENCHIFY_API_URL}/v1/fixer`, {
const response = await fetch(`${BENCHIFY_API_URL}/fixer`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -74,13 +74,13 @@ export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Pro
const patchResult = applyPatch(file.contents, result.diff);
return {
path: file.path,
contents: typeof patchResult === 'string' ? patchResult : file.contents
content: typeof patchResult === 'string' ? patchResult : file.content
};
}
return file;
});

return repairedFiles;
return { repairedFiles, buildOutput: result.build_output };
} catch (error) {
if (error instanceof Error) {
console.error('Benchify Processing Error:', {
Expand Down
4 changes: 2 additions & 2 deletions lib/e2b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
await sandbox.files.write(
files.map(file => ({
path: `/home/user/app/${file.path}`,
data: file.contents
data: file.content
}))
);

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

Expand Down
4 changes: 2 additions & 2 deletions lib/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ if (!OPENAI_API_KEY) {
// Schema for a single file
const fileSchema = z.object({
path: z.string(),
contents: z.string()
content: z.string()
});

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

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RESPONSE FORMAT:
You must return a valid JSON array of file objects. Each file object must have exactly this structure:
{
"path": "string (relative path to the file)",
"contents": "string (the complete file contents)"
"content": "string (the complete file content)"
}

Do not include any markdown formatting, code blocks, or explanatory text. The response must be pure JSON.`;
Expand Down
2 changes: 1 addition & 1 deletion lib/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';
// Benchify API schema - matching the exact format in the API docs
export const benchifyFileSchema = z.array(z.object({
path: z.string(),
contents: z.string()
content: z.string()
}));

export const benchifyRequestSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Process } from '@e2b/sdk';

export interface GeneratedFile {
path: string;
contents: string;
content: string;
}

export interface SandboxFile {
Expand Down