Skip to content

Commit

Permalink
Merge pull request #7 from KishinNext/release-candidate/improve_readm…
Browse files Browse the repository at this point in the history
…e_docs

chore: improve README.md documentation
  • Loading branch information
KishinNext authored Aug 30, 2023
2 parents 33bd5f3 + 0c3c566 commit 0acf7fa
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
74 changes: 64 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,68 @@ secrets:
token: ''
organization: ''
database:
url: 'postgresql://postgres:postgres@localhost:5432/Adventureworks'
url: 'postgresql://postgres:postgres@host.docker.internal:5432/Adventureworks'
slack:
slack_bot_token: ''
slack_signing_secret: ''
slack_bot_user_id: ''
metabase:
metabase_url: 'http://localhost:3000'
metabase_url: 'http://host.docker.internal:3000'
content_type: 'application/json'
metabase_session: 'session for metabase'
collection_parent: 'Collection parent: int'
database_id: 'database id: int'
logging_level: DEBUG
```
> Please note that the database URL and metabase_url correspond to the address of your desired database connection and your Metabase instance, respectively. The URL provided above is for the AdventureWorks database and a Metabase instance, both running locally through Docker. You're welcome to adjust it to reflect your own database URL
The API tokens are not necessary for this assistant. However, you do need to have an OpenAI API token to access the GPT-4 model. Additionally, please provide the "Organization ID" for your organization. For database access, it is recommended to create a read-only user specifically for this assistant to ensure secure and limited access to the database.
For Slack access, you can follow this [tutorial](https://www.youtube.com/watch?v=3jFXRNn2Bu8&t=1510s&ab_channel=DaveEbbelaar), also this [page](https://docs.datalumina.io/3y3XPD66nBJaub/b/2808AFE6-41C8-46EF-A4AB-52A4B021993A/Part-1-%E2%80%94-Slack-Setup) is useful.
### Slack
To set up the Slack integration, you'll need to create a Slack app. For guidance on Slack configuration, please refer to this [tutorial](https://www.youtube.com/watch?v=3jFXRNn2Bu8&t=1510s&ab_channel=DaveEbbelaar).
Additionally, this documentation page is a valuable resource for obtaining the **Slack_Bot_id** and configuring the app [page](https://docs.datalumina.io/3y3XPD66nBJaub/b/2808AFE6-41C8-46EF-A4AB-52A4B021993A/Part-1-%E2%80%94-Slack-Setup).
### Database
Querycrafter is compatible with Postgres databases. You have the option to either utilize your own database or employ the one showcased in this demo.
For this demonstration, I've implemented the AdventureWorks database for PostgreSQL. You can download it [here](https://github.com/lorint/AdventureWorks-for-Postgres)
Please ensure you've set this up before proceeding to the subsequent steps.
### Metabase
For Metabase configuration, there are simple parts:
First get the latest image of Metabase:
```
docker pull metabase/metabase:v0.46.4
```

Then run the image:
```
docker run -d -p 3000:3000 --name metabase metabase/metabase:v0.46.4
```

Connect your database to Metabase (if you use the AdventureWorks database locally here is the configuration):

![img.png](assets/database_config.png)


Get the url of Metabase:

For Metabase configuration, there there are simple parts:

The metabase_url, is the URL for Metabase.
The Metabase session is a unique id for each instance of Metabase, you can follow this [tutorial](https://www.metabase.com/learn/administration/metabase-api#authenticate-your-requests-with-a-session-token) to get it.
The parent collection is a necessary component as it serves as the storage location for all the dashboards and subcollections created by the assistant. You can find the id of a collection in the URL.
The database ID refers to the specific database that Metabase will utilize for running queries. You can locate this ID in the URL within Metabase's admin panel.
The parent collection is a necessary component as it serves as the storage location for all the dashboards and subcollections created by the assistant. You can find the id of a collection in the URL. For example, the id of the "gg" collection is 2.

![img.png](assets/collection_id.png)

The database ID refers to the specific database that Metabase will utilize for running queries. You can locate this ID in the URL within Metabase's admin panel. For example, the id of the "Adventureworks" database is 2.

![img.png](assets/database_id.png)

### Docker

With the "development.yaml" file ready, you can run the docker-compose to build and run the containers:
```
Expand All @@ -54,8 +90,26 @@ To debug the agent in routers/slack.py, you have the option to modify the parame
agent = GeneralAgent(engine=engine, verbose=True)
```

Additionally, you have the option to use ngrok to establish a connection between your local environment and Slack. Ngrok provides a secure port forward functionality, allowing Slack to discover your local endpoint. To achieve this, you can utilize the following command:
### Ngrok
Additionally, you can use ngrok to establish a connection between your local environment and Slack. Ngrok provides a secure port forward functionality, allowing Slack to discover your local endpoint. To achieve this, you can utilize the following command:
```
ngrok http http://0.0.0.0:8080
```
Finally, you can use the QueryCrafter agent in your chat!!
Copy the forwarding URL and paste it in the "Event Subscriptions" section of your Slack app. You must also add "/slack/events" to the end of the URL to ensure that Slack can access the correct endpoint.
```
https://<your_ngrok_forwarding_url>/slack/events
```

Remember that you have to add your Slack app to your workspace before you can use it.
You can follow this [tutorial](https://www.youtube.com/watch?v=dKSiV0s0Jkg) to add your Slack app to your workspace.


Finally, you can use the QueryCrafter agent in your chat!!

- Some examples :) :

![img.png](assets/questions_to_querycrafter.png)

- Here is the result:

![img.png](assets/dashboard.png)
Binary file added assets/collection_id.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/database_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/database_id.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/questions_to_querycrafter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0acf7fa

Please sign in to comment.