diff --git a/.circleci/config.yml b/.circleci/config.yml index db7c4ef5b..950a6cc0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1094,6 +1094,26 @@ jobs: working_directory: ~/project steps: - checkout + # New steps to run Node.js test + - run: + name: Install Node.js + command: | + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get install -y nodejs + node --version + npm --version + + - run: + name: Install Node.js dependencies + command: | + npm install @google-cloud/vertexai + npm install --save-dev jest + + - run: + name: Run Vertex AI tests + command: | + npx jest tests/pass_through_tests/test_vertex.test.js --verbose + no_output_timeout: 30m - run: name: Install Docker CLI (In case it's not already installed) command: | @@ -1172,6 +1192,26 @@ jobs: - run: name: Wait for app to be ready command: dockerize -wait http://localhost:4000 -timeout 5m + # New steps to run Node.js test + - run: + name: Install Node.js + command: | + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get install -y nodejs + node --version + npm --version + + - run: + name: Install Node.js dependencies + command: | + npm install @google-cloud/vertexai + npm install --save-dev jest + + - run: + name: Run Vertex AI tests + command: | + npx jest tests/pass_through_tests/test_vertex.test.js --verbose + no_output_timeout: 30m - run: name: Run tests command: | @@ -1179,7 +1219,6 @@ jobs: ls python -m pytest -vv tests/pass_through_tests/ -x --junitxml=test-results/junit.xml --durations=5 no_output_timeout: 120m - # Store test results - store_test_results: path: test-results diff --git a/tests/pass_through_tests/test_local_vertex.js b/tests/pass_through_tests/test_local_vertex.js new file mode 100644 index 000000000..1f2eaea33 --- /dev/null +++ b/tests/pass_through_tests/test_local_vertex.js @@ -0,0 +1,40 @@ +const { VertexAI, RequestOptions } = require('@google-cloud/vertexai'); + +const vertexAI = new VertexAI({ + project: 'adroit-crow-413218', + location: 'us-central1', + apiEndpoint: "localhost:4000/vertex-ai" +}); + +// Create customHeaders using Headers +const customHeaders = new Headers({ + "X-Litellm-Api-Key": "sk-1234" +}); + +// Use customHeaders in RequestOptions +const requestOptions = { + customHeaders: customHeaders +}; + +const generativeModel = vertexAI.getGenerativeModel( + { model: 'gemini-1.0-pro' }, + requestOptions +); + +async function testModel() { + try { + const request = { + contents: [{role: 'user', parts: [{text: 'How are you doing today tell me your name?'}]}], + }; + const streamingResult = await generativeModel.generateContentStream(request); + for await (const item of streamingResult.stream) { + console.log('stream chunk: ', JSON.stringify(item)); + } + const aggregatedResponse = await streamingResult.response; + console.log('aggregated response: ', JSON.stringify(aggregatedResponse)); + } catch (error) { + console.error('Error:', error); + } +} + +testModel(); \ No newline at end of file