From 4f007aca80b2050ae80d44d2d10d28f03d6c5e19 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Thu, 19 Oct 2023 20:03:13 -0700 Subject: [PATCH] GCP credential fixes (#23) * Adds Vertex as an option, query param saving * GCP credential fixes --- .github/workflows/deploy-production.yaml | 2 +- Dockerfile | 2 +- README.md | 7 +++++-- main.py | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml index 486894e..15146e2 100644 --- a/.github/workflows/deploy-production.yaml +++ b/.github/workflows/deploy-production.yaml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - name: Write Google Vertex credentials file - run: echo "${{ secrets.GOOGLE_VERTEX_AI_CREDENTIALS }}" > .google_vertex_ai_credentials.json + run: echo "${{ secrets.GOOGLE_VERTEX_AI_CREDENTIALS }}" > ./.google_vertex_ai_credentials.json - run: flyctl deploy --wait-timeout 600 env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/Dockerfile b/Dockerfile index ba78c14..49f6a2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ COPY ./pyproject.toml ./poetry.lock* ./ RUN poetry install --no-interaction --no-ansi --no-root --no-directory -COPY ./*.py ./ +COPY ./*.py ./.google_vertex_ai_credentials.jso[n] ./ RUN poetry install --no-interaction --no-ansi diff --git a/README.md b/README.md index 79128e4..6aaf3e3 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,9 @@ If you'd like to add or swap in different base retrievers (e.g. if you want to u export OPENAI_API_KEY= export TAVILY_API_KEY= -# for Anthropic and Vertex models +# for Anthropic # remove models from code if unused ANTHROPIC_API_KEY= -GOOGLE_APPLICATION_CREDENTIALS= # if you'd like to use the You.com retriever export YDC_API_KEY= @@ -36,6 +35,10 @@ export LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" export LANGCHAIN_API_KEY= export LANGCHAIN_PROJECT= ``` + +You will also need to put your Google Cloud credentials in a JSON file under `.google_vertex_ai_credentials.json` in the main directory if you would like to +use Google Vertex as an option. If you're not using Vertex, you'll need to remove `ChatVertexAI` from `main.py`. + 3. Start the Python backend with `poetry run make start`. 4. Install frontend dependencies by running `cd nextjs`, then `yarn`. 5. Run the frontend with `yarn dev` for frontend. diff --git a/main.py b/main.py index a3a6949..c03cfb7 100644 --- a/main.py +++ b/main.py @@ -291,6 +291,10 @@ def create_chain( ) +dir_path = os.path.dirname(os.path.realpath(__file__)) + +os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = dir_path + "/" + ".google_vertex_ai_credentials.json" + llm = ChatOpenAI( model="gpt-3.5-turbo-16k", # model="gpt-4",