This starter kit will let you quickly get started with data.world's AI Context Engine™. It is a simple Streamlit app that demonstrates how to use the data.world API to send a question to the AI Context Engine and display its response.
- Python v3.12 or later
- Poetry v1.8.3 or later
- A data.world account, with an AI Context Engine™ License and available Knowledge Tokens
First, fetch this repo however you like:
-
Clone it using the web URL
git clone https://github.com/datadotworld/ddw-streamlit-starter-kit.git
or
-
Use the GitHub CLI
gh repo clone datadotworld/ddw-streamlit-starter-kit
or
- Download it via this link ddw-streamlit-starter-kit.zip and unzip it.
Then, navigate to the project directory:
$ cd ddw-streamlit-starter-kit
Get a data.world token (either as an individual user for development, or from a service account for deployment), copy secrets.toml.example
to .streamlit/secrets.toml
, replacing the placeholder token:
[ddw]
api_endpoint = "https://api.data.world"
token = "apikey123"
In the vast majority of most cases, you'll be able to leave the default api_endpoint
value as is.
There are a multitude of ways to set up a Python virtual environment. Here, we will use Poetry. From the root of the project you cloned or downloaded:
$ poetry --version # Ensure you have a recent version of Poetry installed
$ poetry install # Installs both production dependencies and development dependencies
$ poetry shell # Activates the virtual environment
Then, you may start the app:
$ streamlit run app.py
This will open a new tab in your default browser with the app running. You'll see two form fields for specifying your organization ID, project ID, and a text field for entering a question. After entering the required information, click the "Get Answer" button to send the question to the AI Context Engine. The response will be displayed below the form. All of this is driven by Streamlit and the app.py
script.
We make use of standard tools in the Python ecosystem for development. We use black
for code formatting, flake8
for linting, and isort
for organizing imports:
# Activate the virtual environment if you haven't already: poetry shell
$ black .
$ flake8 .
$ isort .
After setting up a secrets.toml
file as described above, you can run the tests:
# Activate the virtual environment if you haven't already: poetry shell
$ pytest
Since this is Streamlit, the easiest way to deploy the app is to use Streamlit's own hosting service. You can find more information in their documentation, "Deploy your app".
We welcome contributions to this project. Please see our CONTRIBUTING.md file for more information.
This project is licensed under the Apache License 2.0. See the LICENSE file for more information.