This directory contains all code required to run a recommendation system agent whose tools and prompts are versioned with
Agent Catalog (agentc
).
- Ensure that you have
python3.12
andpoetry
installed.python3 -m pip install poetry
- Clone this repository and
agent-catalog
in the same parent repository -- make sure that you have an SSH key setup!git clone [email protected]:couchbaselabs/agent-catalog.git git clone [email protected]:couchbaselabs/agent-catalog-example.git
- Navigate to this directory (
agent-catalog-example
), and install the dependencies frompyproject.toml
. Be sure to modify the$LOCATION_OF_LOCAL_AGENT_CATALOG_REPO
line to the location of the clonedagent-catalog
repository. Use--with controlflow
to use the ControlFlow backend (more examples with other agent frameworks are coming soon!).Tip: Running in verbose mode (withcd agent-catalog-example/recommendation_system sed -i -e 's|\$LOCATION_OF_LOCAL_AGENT_CATALOG_REPO|'"$PWD/../../agent-catalog"'|g' pyproject.toml poetry install --with controlflow
-v
flag) would be beneficial if you are a windows user or the installation seems to be taking more time. - You should now have the
agentc
command line tool installed. Test your installation by running theagentc
command (the first run of this command will also compile libraries like Numpy, subsequent runs will be faster).poetry shell agentc
- Copy the
.env.example
file into a.env
file, and update the environment variables appropriately.cp .env.example .env vi .env
For the remainder of the commands in this README, we assume the current working directory is recommendation_system
.
Now, we need some data in Couchbase!
-
Create a Couchbase instance (either locally or on Capella). You'll need a cluster with KV, N1QL, FTS, and Analytics (CBAS). We'll be using FTS for its vector index support and analytics to transform our agent activity. _If you have Docker installed, you can run the command below to quickly spin-up a Couchbase instance:
docker run -d travel-example-db -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase`
-
Create a bucket
ecommerce
with default config. -
Register your Couchbase connection string, username, and password in the
.env
file. -
Run the
setup/setup_script.sh
which does the following: i. Cleans the dataset present indataset/smartphones.csv
and push the data to the Couchbase Cluster ii. Embeds the fielddisplay
so we can do vector search on top of it. iii. Creates vector indexmobile-index
over the display field.chmod +x setup/setup_script.sh ./setup/setup_script.sh
For Capella instances, see the link here for instructions on how to do so using the Capella UI (using the Search -> QUICK INDEX screen).
We are now ready to start using Agent Catalog and ControlFlow to build agents!
- In the
.env
file, add your OpenAI API key:OPENAI_API_KEY=[INCLUDE KEY HERE]
- We have defined 4 tools in the
tools
directory spread across files of multiple types (.py
,.sqlpp
,.yaml
):We must now "index" our tools for Agent Catalog to serve to ControlFlow for use in its agentic workflows. Use thels tools # custom_membership.py # get_product_link.yaml # get_relevant_display.yaml # get_relevant_mobile.sqlpp
index
command to create a local catalog, and point to where all of our tools are located.The local catalog, by default, will appear asagentc index tools agentc publish tool --bucket 'ecommerce'
.agent_catalog/tool_catalog.json
. To publish these tools to a database and leverage the versioning capabilities of Agent Catalog, use the subsequentpublish
command after running theindex
command. (Note that thispublish
step isn't necessary to continue with this tutorial.) - Repeat this indexing step for the
prompts
folder, where all of our prompts are located.Similarly, you are free to publish your prompts to a database with the sameagentc index prompts agentc publish prompt --bucket 'ecommerce'
publish
command (again, after theindex
command). (Note that thispublish
step isn't necessary to continue with this tutorial.) - Now that we have our tools available, our agent is ready to execute!
Execute the python script app.py and interact with the agentic workflow
python app.py