RAG With AWEL
In this example, we will show how to use the AWEL library to create a RAG program.
Now, let us create a python file first_rag_with_awel.py
.
In this example, we will load your knowledge from a URL and store it in a vector store.
Install Dependencies
First, you need to install the dbgpt
library.
pip install "dbgpt[rag]>=0.5.2"
Prepare Embedding Model
To store the knowledge in a vector store, we need an embedding model, DB-GPT supports a lot of embedding models, here are some of them:
- Open AI(API)
- text2vec(local)
- Embedding API Server(cluster)
from dbgpt.rag.embedding import DefaultEmbeddingFactory
embeddings = DefaultEmbeddingFactory.openai()
from dbgpt.rag.embedding import DefaultEmbeddingFactory
embeddings = DefaultEmbeddingFactory.default("/data/models/text2vec-large-chinese")
If you have deployed DB-GPT cluster and API server , you can connect to the API server to get the embeddings.
from dbgpt.rag.embedding import DefaultEmbeddingFactory
embeddings = DefaultEmbeddingFactory.remote(
api_url="http://localhost:8100/api/v1/embeddings",
api_key="{your_api_key}",
model_name="text2vec"
)