This is a sample eCommerce application using Hasura PromptQL. Follow the steps below to set it up.
-
Clone the repo:
git clone https://github.com/hasura/promptql-sample-ecommerce-app
-
Install Hasura DDN CLI:
curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v4/get.sh | bash
-
Log in to Hasura via CLI:
ddn auth login
-
Change to the
ddn_ecommerce
directory:cd ddn_ecommerce
-
Set up environment variables:
- Copy the
.env.example
file:cp .env.example .env
- Edit
.env
to include your API keys:- Get your Hasura DDN PAT:
Update the
ddn auth print-pat
HASURA_DDN_PAT
variable in.env
with the obtained PAT. - Get your Anthropic API key (this will be used for executing PromptQL queries) and update the
ANTHROPIC_API_KEY
variable in.env
. - Get your OpenAI API key (this will be used for creating the vector embeddings of product reviews) and update the
APP_TYPESCRIPT_OPENAI_API_KEY
variable in.env
. - Get your PromptQL API key:
- Create a Hasura DDN project:
ddn project create
- Go to Hasura DDN Console > Select your project > Go to Settings (bottom left corner) > Go to PromptQL under Project Settings > Enable PromptQL > Generate New API Key (remember to copy the key).
- Update the
PROMPTQL_SECRET_KEY
variable in.env
with the obtained API key.
- Create a Hasura DDN project:
- Get your Hasura DDN PAT:
- Copy the
-
Start the playground server from the
ddn_ecommerce
directory:ddn run docker-start
-
Create embeddings for the data.
curl -X POST http://localhost:3000/graphql -H 'content-type: application/json' -d '{ "query": "mutation { vectorize }" }'
-
Open the Hasura Console: Go to PromptQL Playground on Hasura Local Console > Click on the gear icon on the top left next to PromptQL Playground > Enter your playground URL (
http://localhost:5000
).
Note: This setup works best on Chrome. Other browsers may experience issues.
You can ask queries like:
- What is Mia Wright's order history?
- What reviews has Jane Smith written?
- Find electronic products less than $300 where the reviews mention they are working great.
- What are the average ratings for each category?
- How much has Bob Brown spent till date?
- What are customers saying about Laptop Pro?
See the power of PromptQL in action!