Skip to content

Commit

Permalink
fix: rename variables in lambda (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirien authored Feb 13, 2024
1 parent 671a16f commit e292687
Show file tree
Hide file tree
Showing 28 changed files with 2,957 additions and 2,111 deletions.
96 changes: 30 additions & 66 deletions aws-cs-langserve/README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,53 @@
# AWS CSharp LangServe Example

## Installation
This example demonstrates how to use deploy a simple app using Pulumi in CSharp.

Install the LangChain CLI if you haven't yet
## Prerequisites

```bash
pip install -U langchain-cli
```
To run this example, you'll need the following tools installed on your machine:

## Adding packages

```bash
# adding packages from
# https://github.com/langchain-ai/langchain/tree/master/templates
langchain app add $PROJECT_NAME

# adding custom GitHub repo packages
langchain app add --repo $OWNER/$REPO
# or with whole git string (supports other git providers):
# langchain app add git+https://github.com/hwchase17/chain-of-verification

# with a custom api mount point (defaults to `/{package_name}`)
langchain app add $PROJECT_NAME --api_path=/my/custom/path/rag
```
1. [Install .NET Core](https://dotnet.microsoft.com/en-us/download)
2. [Install Pulumi](https://www.pulumi.com/docs/install/)
3. [Configure AWS](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/)
4. [Install Docker](https://docs.docker.com/get-docker/)
5. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
6. [Install the LangChain CLI](https://python.langchain.com/docs/langserve#installation)

Note: you remove packages by their api path

```bash
langchain app remove my/custom/path/rag
```

## Setup LangSmith (Optional)
LangSmith will help us trace, monitor and debug LangChain applications.
LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
If you don't have access, you can skip this section


```shell
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=<your-api-key>
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
```

## Launch LangServe

```bash
langchain serve
```

## Deploying to AWS
## Deploying to AWS using Pulumi

Run the following command to deploy your LangServe app to AWS:

```bash
git clone https://github.com/pulumi/examples.git
cd examples/aws-cs-langserve
pulumi stack init <your-stack-name>
pulumi config set open-api-key --secret # Enter your OpenAI API key
pulumi up
```

This will output the URL of your LangServe app. You can use this URL to make requests to your app.
This last 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.

## Running in Docker
The whole deployoment process will take a couple of minutes. Once it's done, you will see the URL of your LangServe app in the output.

This project folder includes a Dockerfile that allows you to easily build and host your LangServe app.

### Building the Image

To build the image, you simply:
```bash
Outputs:
url: "http://<dns>.elb.amazonaws.com"

```shell
docker build . -t my-langserve-app
Resources:
+ 27 created
```

If you tag your image with something other than `my-langserve-app`,
note it for use in the next step.
You can now access the LangServe playground by adding `/openai/playground` to the URL you got from the output.

### Running the Image Locally
> [!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.
To run the image, you'll need to include any environment variables
necessary for your application.
## Clean up

In the below example, we inject the `OPENAI_API_KEY` environment
variable with the value set in my local environment
(`$OPENAI_API_KEY`)
To clean up the resources created by this example, run the following command:

We also expose port 8080 with the `-p 8080:8080` option.

```shell
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 my-langserve-app
```bash
pulumi destroy
```

You will be prompted to confirm the deletion of the resources. Once confirmed, Pulumi will delete all the resources created by this example.
3 changes: 1 addition & 2 deletions aws-cs-langserve/app/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from langchain.chat_models import ChatAnthropic, ChatOpenAI
from langchain_openai import ChatOpenAI
from langserve import add_routes

app = FastAPI(
Expand Down
854 changes: 521 additions & 333 deletions aws-cs-langserve/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions aws-cs-langserve/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ uvicorn = "^0.23.2"
langserve = {extras = ["server"], version = ">=0.0.30"}
pydantic = "<2"
openai = "^1.10.0"
langchain-openai = "^0.0.5"


[tool.poetry.group.dev.dependencies]
Expand Down
96 changes: 30 additions & 66 deletions aws-go-langserve/README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,53 @@
# AWS Go LangServe Example

## Installation
This example demonstrates how to use deploy a simple app using Pulumi in Go.

Install the LangChain CLI if you haven't yet
## Prerequisites

```bash
pip install -U langchain-cli
```
To run this example, you'll need the following tools installed on your machine:

## Adding packages

```bash
# adding packages from
# https://github.com/langchain-ai/langchain/tree/master/templates
langchain app add $PROJECT_NAME

# adding custom GitHub repo packages
langchain app add --repo $OWNER/$REPO
# or with whole git string (supports other git providers):
# langchain app add git+https://github.com/hwchase17/chain-of-verification

# with a custom api mount point (defaults to `/{package_name}`)
langchain app add $PROJECT_NAME --api_path=/my/custom/path/rag
```
1. [Install Go](https://golang.org/doc/install)
2. [Install Pulumi](https://www.pulumi.com/docs/install/)
3. [Configure AWS](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/)
4. [Install Docker](https://docs.docker.com/get-docker/)
5. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
6. [Install the LangChain CLI](https://python.langchain.com/docs/langserve#installation)

Note: you remove packages by their api path

```bash
langchain app remove my/custom/path/rag
```

## Setup LangSmith (Optional)
LangSmith will help us trace, monitor and debug LangChain applications.
LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
If you don't have access, you can skip this section


```shell
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=<your-api-key>
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
```

## Launch LangServe

```bash
langchain serve
```

## Deploying to AWS
## Deploying to AWS using Pulumi

Run the following command to deploy your LangServe app to AWS:

```bash
git clone https://github.com/pulumi/examples.git
cd examples/aws-go-langserve
pulumi stack init <your-stack-name>
pulumi config set open-api-key --secret # Enter your OpenAI API key
pulumi up
```

This will output the URL of your LangServe app. You can use this URL to make requests to your app.
This last 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.

## Running in Docker
The whole deployoment process will take a couple of minutes. Once it's done, you will see the URL of your LangServe app in the output.

This project folder includes a Dockerfile that allows you to easily build and host your LangServe app.

### Building the Image

To build the image, you simply:
```bash
Outputs:
url: "http://<dns>.elb.amazonaws.com"

```shell
docker build . -t my-langserve-app
Resources:
+ 27 created
```

If you tag your image with something other than `my-langserve-app`,
note it for use in the next step.
You can now access the LangServe playground by adding `/openai/playground` to the URL you got from the output.

### Running the Image Locally
> [!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.
To run the image, you'll need to include any environment variables
necessary for your application.
## Clean up

In the below example, we inject the `OPENAI_API_KEY` environment
variable with the value set in my local environment
(`$OPENAI_API_KEY`)
To clean up the resources created by this example, run the following command:

We also expose port 8080 with the `-p 8080:8080` option.

```shell
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 my-langserve-app
```bash
pulumi destroy
```

You will be prompted to confirm the deletion of the resources. Once confirmed, Pulumi will delete all the resources created by this example.
3 changes: 1 addition & 2 deletions aws-go-langserve/app/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from langchain.chat_models import ChatAnthropic, ChatOpenAI
from langchain_openai import ChatOpenAI
from langserve import add_routes

app = FastAPI(
Expand Down
84 changes: 0 additions & 84 deletions aws-go-langserve/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,3 @@ require (
github.com/pulumi/pulumi-docker/sdk/v4 v4.5.1
github.com/pulumi/pulumi/sdk/v3 v3.103.1
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/charmbracelet/bubbles v0.16.1 // indirect
github.com/charmbracelet/bubbletea v0.24.2 // indirect
github.com/charmbracelet/lipgloss v0.7.1 // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/djherbis/times v1.5.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/opentracing/basictracer-go v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pgavlin/fx v0.1.6 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.6.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230725213213-b022f6e96895 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/frand v1.4.2 // indirect
)
Loading

0 comments on commit e292687

Please sign in to comment.