-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add smoke test for function calling (#199)
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
83 changes: 83 additions & 0 deletions
83
llm_demo/vertexai_function_calling.int.tests.cloudbuild.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright 2023 Google LLC | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
steps: | ||
- id: "Deploy to Cloud Run" | ||
name: "gcr.io/cloud-builders/gcloud:latest" | ||
dir: llm_demo | ||
entrypoint: /bin/bash | ||
args: | ||
- "-c" | ||
- | | ||
gcloud run deploy ${_SERVICE} \ | ||
--source . \ | ||
--region ${_REGION} \ | ||
--no-allow-unauthenticated \ | ||
--update-env-vars ORCHESTRATION_TYPE=${_ORCHESTRATION_TYPE} | ||
- id: "Test Frontend" | ||
name: "gcr.io/cloud-builders/gcloud:latest" | ||
entrypoint: /bin/bash | ||
env: # Set env var expected by app | ||
args: | ||
- "-c" | ||
- | | ||
export URL=$(gcloud run services describe ${_SERVICE} --region ${_REGION} --format 'value(status.url)') | ||
export ID_TOKEN=$(gcloud auth print-identity-token --audiences $$URL) | ||
export ORCHESTRATION_TYPE=${_ORCHESTRATION_TYPE} | ||
# Test `/` route | ||
curl -c cookies.txt -si --fail --show-error -H "Authorization: Bearer $$ID_TOKEN" $$URL | ||
# Test `/chat` route should fail | ||
msg=$(curl -si --show-error \ | ||
-X POST \ | ||
-H "Authorization: Bearer $$ID_TOKEN" \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{"prompt":"How can you help me?"}' \ | ||
$$URL/chat) | ||
if grep -q "400" <<< "$msg"; then | ||
echo "Chat Handler Test: PASSED" | ||
else | ||
echo "Chat Handler Test: FAILED" | ||
echo $msg && exit 1 | ||
fi | ||
# Test `/chat` route | ||
curl -b cookies.txt -si --fail --show-error \ | ||
-X POST \ | ||
-H "Authorization: Bearer $$ID_TOKEN" \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{"prompt":"How can you help me?"}' \ | ||
$$URL/chat | ||
- id: "Delete image and service" | ||
name: "gcr.io/cloud-builders/gcloud" | ||
entrypoint: "/bin/bash" | ||
args: | ||
- "-c" | ||
- | | ||
gcloud artifacts docker images delete $_GCR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$_SERVICE --quiet | ||
gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet | ||
serviceAccount: "projects/$PROJECT_ID/serviceAccounts/[email protected]" # Necessary for ID token creation | ||
options: | ||
logging: CLOUD_LOGGING_ONLY # Necessary for custom service account | ||
dynamic_substitutions: true | ||
|
||
substitutions: | ||
_GCR_HOSTNAME: ${_REGION}-docker.pkg.dev | ||
_SERVICE: demo-service-${BUILD_ID} | ||
_REGION: us-central1 | ||
_ORCHESTRATION_TYPE: vertexai-function-calling |