This project provides an implementation of API clients for fetching embeddings from various LLM providers.
Currently supported APIs:
You can find sample programs that demonstrate how to use the client packages to fetch the embeddings in cmd directory of this project.
Finally, the document package provides an implementation of simple document text splitters, heavily inspired by the popular Langchain framework.
It's essentially a Go rewrite of character and recursive character text splitters from the Langchain framework with minor modifications, but more or less identical results.
Note
Each client package lets you initialize a default API client for a specific embeddings provider by reading the API keys from environment variables
Here's a list of the env vars for each supported client
OPENAI_API_KEY: Open AI API token
COHERE_API_KEY: Cohere API token
VERTEXAI_TOKEN: Google Vertex AI API token (can be fetch bygcloud auth print-access-tokenonce you've authenticated)VERTEXAI_MODEL_ID: Embeddings model (at the moment onlytextembedding-gecko@00ormultimodalembedding@001are available)GOOGLE_PROJECT_ID: Google Project IDVOYAGE_API_KEY: VoyageAI API key
VOYAGE_API_KEY: Voyage AI API key
Important
You must enable access to Bedrock embedding models See here: https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html#add-model-access
AWS_REGION: AWS region
Usual AWS env vars as read by the AWS SDKs i.e. AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.
The project provides a simple nix flake tha leverages gomod2nix for consistent Go environments and builds.
To get started just run
nix developAnd you'll be dropped into development shell.
In addition, each command is exposed as a nix app so you can run them as follows:
nix run ".#vertexai" -- -helpNOTE: gomod2nix vendors dependencies into nix store so every time you add a new dependency you must run gomod2nix generate that updates gomod2nix.toml
Yes please!