AWS Python LangServe example
A minimal Langserve AWS Python Pulumi program
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-py-langservecd pulumi-examples/aws-py-langserveThis example demonstrates how to deploy a simple LangServe app using Pulumi in Python.
Prerequisites#
- Install Pulumi
- Configure AWS credentials
- Install Python
- Install Docker
- Install the AWS CLI
- Install the LangChain CLI
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init dev -
Set the AWS region to deploy into:
Terminal window pulumi config set aws:region us-east-2 -
Set your OpenAI API key:
Terminal window pulumi config set open-api-key --secret -
Install dependencies:
Terminal window python3 -m venv venvsource venv/bin/activatepip install -r requirements.txt -
Deploy the stack:
Terminal window pulumi upThis command will show you a preview of the resources that will be created. After reviewing the changes, you will be prompted to continue. Once confirmed, Pulumi will deploy your LangServe app to AWS.
The whole deployment process will take a couple of minutes. Once it’s done, you will see the URL of your LangServe app in the output.
Outputs:url: "http://<dns>.elb.amazonaws.com"Resources:+ 27 createdYou can now access the LangServe playground by adding
/openai/playgroundto the URL you got from the output.[!NOTE] It may take a few minutes for the load balancer to be ready to accept requests. If you see a 503 error, wait a few minutes and try again.
Cleaning up#
To clean up the resources created by this example, run the following commands. You will be prompted to confirm the deletion of the resources.
pulumi destroypulumi stack rm