This is a repository that contains the code for the article RAG is more than embeddings. Head over to the Timescale blog to read the article if you haven't already. The code is compatible for python >= 3.9.
- First install all the required dependencies in the
requirements.txtfile
pip install -r requirements.txt
-
Make sure to create a
.envfile that has the same environment variables as our.env.examplefile. You can get your DB_URL after creating a Timescale instance by following the instructions here. -
Next, ingest in some Github Issues from the
bigcode/the-stack-github-issuesdataset by running thescripts/ingest.pyfile. This will crawl the first 100 issues that match the list of whitelisted repos in our file. We can do so by running the command below.
python3 ./scripts/ingest.py- We can then test the function calling ability of our model by running the
scripts/eval.pyfile to verify that our model is choosing the right tool with respect to a user query. We can do so by running the command below.
python3 ./scripts/eval.py- In order to perform embedding search, we can define a new
.executefunction inside our tools themselves. This allows us to call a.execute()function when the tool is selected to immediately return a list of relevant results. To see this in action, run the command below and we'll fetch the top 10 relevant summaries from our database related to thekubernetes/kubernetesrepository using embedding search.
python3 ./scripts/embedding_search.py- Lastly, we'll put it all together in the
agent.pyfile where we'll create a one-step agent that'll be able to answer questions about specific repositories in our database. We can run this agent by executing the command below.
python3 ./scripts/agent.py