Skip to content

Commit

Permalink
fix: Checked env
Browse files Browse the repository at this point in the history
  • Loading branch information
asafgardin committed Dec 4, 2024
1 parent 8ff04de commit e2129a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/studio/conversational-rag/rag-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if (isBrowser) {
} else {
console.log(`File found: ${filePath}`);
}

await uploadGetUpdateDelete(filePath, Date.now().toString());
console.log('=== First operation completed ===\n');
await sleep(2000);
Expand Down
6 changes: 3 additions & 3 deletions src/files/NodeFilesHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export class NodeFilesHandler extends BaseFilesHandler {
async prepareFormDataRequest(file: FilePathOrFileObject): Promise<FormDataRequest> {
console.log('Preparing form data request for Node.js');
try {
const FormData = await import('form-data').then(m => m.default || m);
const FormData = await import('form-data').then((m) => m.default || m);
console.log('Successfully imported form-data module');

const formData = new FormData();
console.log('Created new FormData instance');

if (typeof file === 'string') {
const fs = await import('fs').then(m => m.default || m);
const fs = await import('fs').then((m) => m.default || m);
if (!fs.existsSync(file)) {
throw new Error(`File not found: ${file}`);
}
Expand Down
4 changes: 4 additions & 0 deletions src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ export const isNode =

export function createFetchInstance(): Fetch {
if (isBrowser || isWebWorker) {
console.log('Creating BrowserFetch instance');
return new BrowserFetch();
}

console.log('Creating NodeFetch instance');
return new NodeFetch();
}

export function createFilesHandlerInstance(): BaseFilesHandler {
if (isBrowser || isWebWorker) {
console.log('Creating BrowserFilesHandler instance');
return new BrowserFilesHandler();
}
console.log('Creating NodeFilesHandler instance');
return new NodeFilesHandler();
}

0 comments on commit e2129a6

Please sign in to comment.