/ai-dial-adapter-vertexai

Primary LanguagePythonApache License 2.0Apache-2.0

Overview

The project implements AI DIAL API for language models and embeddings from Vertex AI.

Supported models:

  • chat-bison@001
  • codechat-bison@001

Supported embeddings:

  • textembedding-gecko@001

Developer environment

This project uses Python>=3.11 and Poetry>=1.6.1 as a dependency manager.

Check out Poetry's documentation on how to install it on your system before proceeding.

To install requirements:

poetry install

This will install all requirements for running the package, linting, formatting and tests.

IDE configuration

The recommended IDE is VSCode. Open the project in VSCode and install the recommended extensions.

The VSCode is configured to use PEP-8 compatible formatter Black.

Alternatively you can use PyCharm.

Set-up the Black formatter for PyCharm manually or install PyCharm>=2023.2 with built-in Black support.

Run

Run the development server:

make serve

Open localhost:5001/docs to make sure the server is up and running.

Environment Variables

Copy .env.example to .env and customize it for your environment:

Variable Default Description
GOOGLE_APPLICATION_CREDENTIALS Filepath to JSON with credentials
DEFAULT_REGION Default region for Vertex AI (e.g. "us-central1")
GCP_PROJECT_ID GCP project ID
LOG_LEVEL INFO Log level. Use DEBUG for dev purposes and INFO in prod
AIDIAL_LOG_LEVEL WARNING AI DIAL SDK log level
WEB_CONCURRENCY 1 Number of workers for the server
TEST_SERVER_URL http://0.0.0.0:5001 Server URL used in the integration tests

Docker

Run the server in Docker:

make docker_serve

Lint

Run the linting before committing:

make lint

To auto-fix formatting issues run:

make format

Test

Run unit tests locally:

make test

Run unit tests in Docker:

make docker_test

Run integration tests locally:

make integration_tests

Clean

To remove the virtual environment and build artifacts:

make clean