Spaces:
Sleeping
Sleeping
File size: 2,711 Bytes
9f2df60 31c360c 9f2df60 31c360c 9f2df60 31c360c 3c5b98e 31c360c 9f2df60 31c360c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # Weaviate Database Setup
This project uses Weaviate Cloud to store retrieval chunks and vectors. The
application generates embeddings through OpenRouter
`openai/text-embedding-3-small` and stores them as self-provided vectors.
## Installation steps
1. Create a new python virtual environment using `python -m venv venv`, activate the environment via `source venv/bin/activate`, install the needed requirements from the `requirements.txt` file if you haven't done it already.
2. Configure `WEAVIATE_CLUSTER_URL`, `WEAVIATE_API_KEY`, and `OPEN_ROUTER_API_KEY`.
3. With the python environment activated, initialize the collections with `python main.py --weaviate init`. Inspect the logs to check whether collection creation was successful.
If you've managed to setup the database and create the collections, the installation process is finished and the database is accessible from the other parts of the program.
## Managing the database
To manage the state of the database directly, multiple useful scripts were developed. The scripts can be called via the `weaviate.py` using the following arguments:
- `-cc` or `--create_collections`: initializes separate collections for different language contents.
- `-dc` or `--delete_collections`: deletes all collections and their contents from the database.
- `-rc` or `--redo_collections`: deletes the collections and creates them again.
- `-ch` or `--checkhealth`: checks the connection to the database and existence of the content collections.
- `-cb` or `--create_backup`: creates a backup of the current state of the database.
- `-rb` pr `--restore_backup`: restores the state of the database from the provided backup\_id.
When changing embedding model, tokenizer, or vector dimensions, rebuild the collections and re-import content:
```bash
python main.py --weaviate redo
python main.py --scrape full
```
Run `python main.py --imports ...` afterward for any local documents that are
part of the knowledge base.
## Data properties
Embeddings are stored in the corresponding language collection with a set of properties that define chunk metadata:
- body (TEXT): text content of the stored embedding.
- chunk\_id (TEXT): ID of the chunk defined by the data processor.
- document\_id (TEXT): ID of the document from which the chunk was derived (also defined by the data processor).
- programs (TEXT\_ARRAY): list of the EMBA programs that were identified in the document of the derived information.
- source (TEXT): source of the information (name of the document or the url).
- date (DATE): date when the data chunk was prepared for the insertion.
## WeaviateService
The WeaviateService class manages the connection and interaction with Weaviate Cloud.
|