Getting started: PromptQL on GitHub
In this guide, you’ll learn how to:
- Set up PromptQL to work with GitHub issues and pull requests
- Install all required prerequisites
- Create and configure the necessary API keys
- Run your PromptQL project in a local environment
- Deploy your project to Hasura DDN for sharing with others
Setup
Create a Hasura account
Sign in to your Hasura account or create a new one if you don’t have one already.
Install the DDN CLI
bash copy curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v4/get.sh | bash
Install Docker
Follow the instructions on the Docker website to install Docker on your machine.
Log in with the CLI
Logging in allows you to connect to the PromptQL runtime which is necessary for development. It also allows you to deploy your project to Hasura DDN.
ddn auth login
Validate the installation
You can verify that the DDN CLI is installed correctly by running:
ddn doctor
Build your PromptQL app
Clone the example project
The example project is already set up to connect PromptQL to any GitHub repo.
git clone https://github.com/hasura/example-promptql-github.git
cd example-promptql-github
Set up your .env file
Set up your .env file with your Anthropic (or OpenAI) API key and GitHub API token.
cp .env.example .env
Add Anthropic API key to .env
Get an api key from https://console.anthropic.com/settings/keys
# .env
...
ANTHROPIC_API_KEY=<your-anthropic-api-key>
To use an OpenAI key instead, you’ll have to set OPENAI_API_KEY
in your .env file and change the environment variable
LLM
to openai
in the compose.yaml file.
Add GitHub API token to .env
Head over to https://github.com/settings/tokens and create an API token.
# .env
...
GITHUB_API_TOKEN=<GITHUB_API_TOKEN>
This token only needs read access to the repo you are interested in.
Set up your GitHub repo
Head to app/connector/github/index.ts
and change the org name and the repo name to something you’d like:
// index.ts
...
const manager = new GitHubIssueSyncManager('<org-name>', '<repo-name>');
if (!process.env.GITHUB_API_TOKEN) {
...
Setup your DDN project
This will create a Hasura DDN cloud project and set up PromptQL keys to connect to the PromptQL runtime.
ddn project init
Fire up your PromptQL project
Build your supergraph.
ddn supergraph build local
Then bring up the PromptQL API server, the engine and the connector
ddn run docker-start
You’ll notice in amongst your Docker logs that your github synchronization has started.
Docker logs
[2024-01-01 12:00:02] Fetching repository metadata…
[2024-01-01 12:00:03] Syncing issues and pull requests…
[2024-01-01 12:00:04] Loading repository contents…
[2024-01-01 12:00:05] GitHub sync complete
If the specified repo has many issues or comments it may take some time to get them all and you may be rate limited. That’s ok, you can go ahead and try PromptQL without the process having fully finished yet.
If you notice some logs regarding GitHub permissions, check that your GitHub API token has the correct permissions for the repo you’re trying to access.
Restarting the app
If you made a mis-step or want to start from scratch, simply restarting the docker containers will reset all state including any loaded data.
ddn run docker-start
Act on your data
Open the PromptQL playground
In another terminal, run
ddn console --local
Browser support: PromptQL playground is supported on all browsers except Firefox and Safari. Support for these browsers should be available shortly.
Ask questions about your GitHub repo
The console is a web app hosted at console.hasura.io that connects to your local PromptQL API and data sources. Your data is processed in the DDN PromptQL runtime but isn’t persisted externally.
Head over to the console and ask a few questions about your GitHub repo.
> What are the open pull requests?
> What kind of questions can I ask?