forked from phoenix/litellm-mirror
test vertex js
This commit is contained in:
parent
4972415372
commit
53e82b7f14
2 changed files with 80 additions and 1 deletions
|
@ -1094,6 +1094,26 @@ jobs:
|
||||||
working_directory: ~/project
|
working_directory: ~/project
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- 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:
|
- run:
|
||||||
name: Install Docker CLI (In case it's not already installed)
|
name: Install Docker CLI (In case it's not already installed)
|
||||||
command: |
|
command: |
|
||||||
|
@ -1172,6 +1192,26 @@ jobs:
|
||||||
- run:
|
- run:
|
||||||
name: Wait for app to be ready
|
name: Wait for app to be ready
|
||||||
command: dockerize -wait http://localhost:4000 -timeout 5m
|
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:
|
- run:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
command: |
|
command: |
|
||||||
|
@ -1179,7 +1219,6 @@ jobs:
|
||||||
ls
|
ls
|
||||||
python -m pytest -vv tests/pass_through_tests/ -x --junitxml=test-results/junit.xml --durations=5
|
python -m pytest -vv tests/pass_through_tests/ -x --junitxml=test-results/junit.xml --durations=5
|
||||||
no_output_timeout: 120m
|
no_output_timeout: 120m
|
||||||
|
|
||||||
# Store test results
|
# Store test results
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: test-results
|
path: test-results
|
||||||
|
|
40
tests/pass_through_tests/test_local_vertex.js
Normal file
40
tests/pass_through_tests/test_local_vertex.js
Normal file
|
@ -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();
|
Loading…
Add table
Add a link
Reference in a new issue