This project provides a Streamlit connector for the open-source vector database, Weaviate.
The Streamlit-Weaviate Connector enables developers to connect to a Weaviate database with the following Python code:
conn = st.connection(
"weaviate",
type=WeaviateConnection,
url=os.getenv("WEAVIATE_URL"),
api_key=os.getenv("WEAVIATE_API_KEY"),
)
We built a Streamlit demo with this connector, called "Magic Chat", designed to search through Magic The Gathering cards with various search options, such as BM25, Semantic Search, Hybrid Search and Generative Search. The live demo is accessible through Streamlit Community Cloud
This project uses poetry
for dependency management. You can find more details about poetry
in its documentation.
- Create a new Python virtual environment:
- Ensure you have python
>=3.11.0
installed pip install poetry
- Install the project:
- Install the project using poetry
-
poetry add git+https://github.com/weaviate/st-weaviate-connection.git
The project includes a demonstration notebook to showcase basic functionalities of the connector (see here demo notebook)
Before you run the Jupyter notebook make sure that you have set the following environment variables
Set environment variables:
WEAVIATE_URL= YOUR WEAVIATE_CLUSTER_URL
WEAVIATE_API_KEY= YOUR WEAVIATE_API_KEY
To set up your Weaviate cluster, follow either of these methods:
- OPTION 1 Create a cluster in WCS (for more details, refer to the Weaviate Cluster Setup Guide)
- OPTION 2 Use Docker-Compose to setup a cluster locally Weaviate Docker Guide
All connector functionality can be found in the connection.py
python file. Documentation about st.connection
can be found here.
Now, you're all set to use the Weaviate Connector for Streamlit. Happy coding!
We encourage open-source contributions. Feel free to suggest improvements, provide feedback, create issues, and submit bug reports!