Skip to content

Commit 79e616b

Browse files
committed
test: Trying integration test
1 parent 18b46a0 commit 79e616b

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
npm install
25-
npm install ai21
25+
npm run build
2626
2727
- name: Run Integration Tests
2828
env:

examples/studio/conversational-rag/rag-engine.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AI21, FileResponse, UploadFileResponse, isBrowser } from 'ai21';
1+
import { AI21, FileResponse, UploadFileResponse } from 'ai21';
22
import path from 'path';
33

44
function sleep(ms) {
@@ -31,7 +31,7 @@ async function uploadGetUpdateDelete(fileInput, path) {
3131
file: fileInput,
3232
path: path,
3333
});
34-
console.log(uploadFileResponse);
34+
console.log(`Uploaded file with id ${uploadFileResponse}`);
3535

3636
let file: FileResponse = await waitForFileProcessing(client, uploadFileResponse.fileId);
3737
console.log(file);
@@ -62,20 +62,21 @@ async function listFiles() {
6262
console.log(files);
6363
}
6464

65-
/* Simulate file upload passing a path to file */
66-
const filePath = path.join(process.cwd(), 'examples/studio/conversational-rag/files', 'meerkat.txt'); // Use process.cwd() to get the current working directory
67-
68-
uploadGetUpdateDelete(filePath, Date.now().toString()).catch(console.error);
69-
70-
/* Simulate file upload passing File instance */
71-
const fileContent = Buffer.from(
72-
'Opossums are members of the marsupial order Didelphimorphia endemic to the Americas.',
73-
);
74-
const dummyFile = new File([fileContent], 'example.txt', { type: 'text/plain' });
65+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
7566

7667
if (isBrowser) {
7768
console.log('Cannot run upload examples in Browser environment');
7869
} else {
70+
/* Simulate file upload passing a path to file */
71+
const filePath = path.join(process.cwd(), 'examples/studio/conversational-rag/files', 'meerkat.txt'); // Use process.cwd() to get the current working directory
72+
73+
uploadGetUpdateDelete(filePath, Date.now().toString()).catch(console.error);
74+
75+
/* Simulate file upload passing File instance */
76+
const fileContent = Buffer.from(
77+
'Opossums are members of the marsupial order Didelphimorphia endemic to the Americas.',
78+
);
79+
const dummyFile = new File([fileContent], 'example.txt', { type: 'text/plain' });
7980
console.log('Running file upload in Node environment');
8081
uploadGetUpdateDelete(dummyFile, Date.now().toString()).catch(console.error);
8182
listFiles().catch(console.error);

0 commit comments

Comments
 (0)