Docker provides a container-based mechanism that ensures consistency and portability as well as environment isolation. For these reasons, deployment of Vectara Answer via Docker may be preferred in some cases.
To demonstrate how to use Vectara Answer with Docker we will now walk through the steps for building an application with the content of Paul Graham's essays website (http://paulgraham.com/).
We call this application AskPG
.
For Docker, you will first need to follow some additional installation steps:
Important
For mac users, please ensure you Docker Desktop is version 4.26.1 or above.
Then, you will need to create the corpus:
- Log into the Vectara Console and create a corpus (https://docs.vectara.com/docs/console-ui/creating-a-corpus).
- Use Vectara Ingest to crawl Paul Graham's website and index it into your data store. Of course, you can also index this data on your own via the API.
Find and open the Docker Desktop application. When you run your application, it will use Docker to host your application inside a container.
Duplicate the secrets.example.toml
file and rename the copy to secrets.toml
.
Edit the secrets.toml
file and change the api_key
value under "default" to be your Vectara API key.
Note
The use of secrets.toml
allows you to create multiple profiles, and store a differnet API key under each profile. This may be helpful if you are working with multiple Vectara Answer apps in parallel. As you can see in the included secrets.example.toml
file we've included the API keys (query only) for the existing datasets that are part of the Quickstart: Feynman, vectara.com and vectara docs.
Note
Some secrets are shared among all profiles, and in order to avoid having to copy that secret under each profile, the code designates a special profile called [general]
— each secret under this profile will be used in any profile (in addition to the profile-specific secrets). For example if you want to add a call to a Huggingface model you can include your hf_token there, or similarly if you want to call OpenAI or Anthropic you can include your key to their API.
Make a duplicate of the config/vectara-website-search/
directory and rename it config/pg-search/
. Update the config/pg-search/config.yaml
file with these changes:
- Change the
corpus_id
value to the ID of the corpus into which you ingested Paul Graham's essays as part of thevectara-ingest
Quickstart. - Change the
account_id
value to the ID of your account. You can click on your username in the top-right corner to copy it to your clipboard. - Change the
app_title
to "Ask Paul Graham".
Edit the config/pg-search/queries.json
file and update the four questions to a set of curated questions you'd like to include in the user interface.
For example, "What is a maker schedule?"
Execute the run script from the Vectara Answer root folder, specifying your configuration as config/pg-search
, and selecting the default
profile from your secrets file:
bash docker/run.sh config/pg-search default
The run.sh
script performs the following steps:
- Runs the
prepare_config.py
python script which creates the.env
file using theconfig.yaml
andsecrets.toml
files - Creates the Docker container and runs this container in your local Docker Desktop instance. The
queries.json
file is loaded dynamically as a Docker volume file. - Exposes the app that runs inside the container, under
localhost:80
- Waits 5 seconds (for the docker container to initialize), and open up a browser at
localhost:80
.
Your application is now up and running in Docker. Try a few queries to see how it works.
You can view your application's logs by running docker logs -f vanswer
. You can stop the application and shut down the container with docker stop vanswer
.
With the Docker setup, the config.yaml
file includes all of your configuration parameters as describe in README, and you can modify those as needed. In this case the parameters do not require the REACT_APP
prefix (as in the case of running locall with the .env
file described in the main README) - see examples in any of the configuration folders that are available in this repo.
With Docker, you can deploy your Vectara Answer application on a cloud service like Render by following these detailed instructions. Deployment on other cloud platforms that support docker like AWS, Azure or GCP is also possible.
Docker needs to be running before you can run your application. Find and open the Docker app.