-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add langgraph orchestration (#447)
Langgraph is introduced in langchain v0.2.0. The legacy langchain agent (implemented in the `langchain-tools` orchestration) is deprecated in langchain v0.2.0 and will soon be removed in the newer version of langchain. This PR adds a new orchestration - langgraph
- Loading branch information
Showing
13 changed files
with
1,212 additions
and
3 deletions.
There are no files selected for viewing
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
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
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,80 @@ | ||
# Copyright 2024 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 | ||
script: | | ||
#!/usr/bin/env bash | ||
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" | ||
script: | | ||
#!/usr/bin/env bash | ||
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/548341735270-compute@developer.gserviceaccount.com" # Necessary for ID token creation | ||
options: | ||
automapSubstitutions: true | ||
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: langgraph |
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
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
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,17 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
from .langgraph_orchestrator import LangGraphOrchestrator | ||
|
||
__ALL__ = ["LangGraphOrchestrator"] |
Oops, something went wrong.