Use this sample app to interact with assistants you have created in the Pinecone console. This app allows you to create a deployable Next.js application to interact with your assistants and their uploaded files.
- Pinecone Assistant
- Azure
azd
templates - Next.js + Tailwind + Python
- Node version 20 or higher
The quickest way to try this azd
template out is using GitHub Codespaces or in a VS Code Dev Container:
You can also get started quickly using a terminal. Simply run azd init -t pinecone-io/pinecone-assistant-azd
to clone the project.
Note
This template is only guaranteed to work on MacOS or Linux. It lacks Windows support, so if you would like to add that, please feel free to do so and submit a PR.
Grab an API key here
There are two required environment variables:
PINECONE_API_KEY
: You can get this from the Pinecone console. If you're running the app locally then add this to your environment. If you're running in Github CI, be sure to add it as a secret in your repository. To configure required secrets for connecting to Azure, simply runazd pipeline config
.PINECONE_ASSISTANT_NAME
: This defaults toexample-assistant
but you can name it whatever you like. If the assistant doesn't exist one will be created during post-deploy operations.
All of the other environment variables in .env.template
are completely optional.
This app uses two additional optional environment variables to control certain features:
SHOW_ASSISTANT_FILES
: Set to 'true' to display the files uploaded to your Pinecone Assistant. Default is 'false'.SHOW_CITATIONS
: Set to 'true' to display citations and references in the assistant's responses. Default is 'true'.
You can set these variables in your .env.local
file:
SHOW_ASSISTANT_FILES=true
SHOW_CITATIONS=true
Before doing anything else be sure to clone the repo. Then, deploy the app:
# follow the prompts to sign in to your Azure account
azd auth login
# install dependencies
npm i
# create a `.env.local` file from the provided template
npm run env:init
# follow the prompts to provision the infrastructure resources in Azure
azd provision
# deploy the app to the provisioned infrastructure
azd deploy
Note:
Be sure to use an Azure environment name =< 6 characters or the deployment will fail.
Note:
If deployment fails initially, try running
sh ./.azd/hooks/postprovision.sh
to make sure your environment is setup properly.
This will provision the necessary Azure resources, run the Python import script to seed your new assistant with the sample PDFs in /assets, and deploy the application to Azure.
To add new files, you can upload them directly in the Pinecone console. Or, download them to your local filesystem in the project's assets/
directory. You can then run
python src/file_manager/upload.py
The script will find any new PDF or text files (ending in pdf
or txt
) in that directory and add them to the Assistant.
Note:
The script ignores any files it's seen before, as tracked in the
processed_files
file. Remove or edit that file, or give the new versions different names, if you want to replace or supplement files you've previously uploaded.
TODO
Experiencing any issues with the sample app? Submit an issue, create a PR, or post in our community forum!