Skip to content

Commit

Permalink
ThejasNU/add langgraph sample agent (#56)
Browse files Browse the repository at this point in the history
* add langgraph sample agent

* Update templates/agents/with_langgraph/README.md

Co-authored-by: Tanvi Johari <[email protected]>

* Update templates/agents/with_langgraph/README.md

Co-authored-by: Tanvi Johari <[email protected]>

* Update templates/agents/with_langgraph/README.md

Co-authored-by: Tanvi Johari <[email protected]>

* Update templates/agents/with_langgraph/README.md

Co-authored-by: Tanvi Johari <[email protected]>

* include suggestions

* include suggestions

* update introduction

* update jupyter notebook instructions

---------

Co-authored-by: Tanvi Johari <[email protected]>
  • Loading branch information
ThejasNU and TJ202 authored Jan 22, 2025
1 parent ac45d30 commit 27c7d63
Show file tree
Hide file tree
Showing 8 changed files with 722 additions and 0 deletions.
17 changes: 17 additions & 0 deletions templates/agents/with_langgraph/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# For tools
CB_CONN_STRING=couchbase://localhost
CB_USERNAME=Administrator
CB_PASSWORD=password

# For agent catalog
AGENT_CATALOG_CONN_STRING=couchbase://localhost
AGENT_CATALOG_USERNAME=Administrator
AGENT_CATALOG_PASSWORD=password
AGENT_CATALOG_BUCKET=travel-sample

# In case of capella instance or if secure connection is required
# replace couchbase with couchbases in AGENT_CATALOG_CONN_STRING and add the following
# AGENT_CATALOG_CONN_ROOT_CERTIFICATE=/path/to/cluster/root/certificate/on/local/system

OPENAI_API_KEY=...
SERPAPI_KEY=...
7 changes: 7 additions & 0 deletions templates/agents/with_langgraph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.agent-catalog
.agent-activity
.data
.model-cache
__pycache__
.env
poetry.lock
130 changes: 130 additions & 0 deletions templates/agents/with_langgraph/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# A Research Agent

This directory contains a starter project for building agents with Couchbase, Langgraph, and Agent Catalog.

## Getting Started

### Running Your Agent

1. Make sure you have Python 3.12 and [Poetry](https://python-poetry.org/docs/#installation) installed!
2. Clone this repository and navigate to this directory (we will assume all subsequent commands are run from here).

```bash
git clone https://github.com/couchbaselabs/agent-catalog
cd templates/agents/with_langgraph
```

3. Agent Catalog uses Git for its versioning.
Run the command below to initialize a new Git repository within the `templates/agents/with_langgraph` directory.

```bash
git init
git add * ; git add .gitignore .env.example
git commit -m "Initial commit"
```

4. Installing anaconda.
We recommend using Anaconda to create a virtual environment for your project to ensure no global dependencies interfere with the project.

[Click here](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) for installation steps.

Once anaconda or any of its distribution is installed, execute the following commands to active the environment.

```bash
conda create -n research-agent python=3.12

conda activate research-agent
```

5. Install this project with Poetry. We recommend using Anaconda to create a virtual environment for your project to ensure no global dependencies interfere with the project.

```bash
poetry install
```

6. Run `agentc` to make sure this project has installed correctly (note that your first run will take a couple of
seconds as certain packages need to be compiled, subsequent runs will be faster).

```bash
Usage: agentc [OPTIONS] COMMAND [ARGS]...

The Couchbase Agent Catalog command line tool.

Options:
-c, --catalog DIRECTORY Directory of the local catalog files. [default: .agent-catalog]
-a, --activity DIRECTORY Directory of the local activity files (runtime data). [default: .agent-activity]
-v, --verbose Flag to enable verbose output. [default: 0; 0<=x<=2]
-i, --interactive / -ni, --no-interactive
Flag to enable interactive mode. [default: i]
--help Show this message and exit.

Commands:
add Interactively create a new tool or prompt and save it to the filesystem (output).
clean Delete all agent catalog related files / collections.
env Return all agentc related environment and configuration parameters as a JSON object.
execute Search and execute a specific tool.
find Find items from the catalog based on a natural language QUERY string or by name.
index Walk the source directory trees (SOURCE_DIRS) to index source files into the local catalog.
publish Upload the local catalog to a Couchbase instance.
status Show the status of the local catalog.
version Show the current version of agentc.

See: https://docs.couchbase.com or https://couchbaselabs.github.io/agent-catalog/index.html# for more information.
```

7. Make sure your Git repo is clean, and run `agentc index` to index your tools and prompts.
Note that `tools` and `prompts` are _relative paths_ to the `tools` and `prompts` folder.

```bash
agentc index tools prompts
```

The command will subsequently crawl the `tools` and `prompts` folder for both tools and prompts.

_Hint: if you've made changes but want to keep the same commit ID for the later "publish" step, use
`git add $MY_FILES` followed by `git commit --amend`!_

8. Start up a Couchbase instance.

1. For those interested in using a local Couchbase instance, see
[here](https://docs.couchbase.com/server/current/install/install-intro.html).
2. For those interested in using Couchbase within a Docker container, run the command below:

```bash
mkdir -p .data/couchbase
docker run -d --name my_couchbase \
-p 8091-8096:8091-8096 -p 11210-11211:11210-11211 \
-v "$(pwd)/.data/couchbase:/opt/couchbase/var" \
couchbase
```

3. For those interested in using Capella, see [here](https://cloud.couchbase.com/sign-up).

This specific agent also uses the `travel-sample` bucket.
You'll need to navigate to your instance's UI (for local instances, this is on http://localhost:8091) to import
this sample bucket.

9. Create a `.env` file using `.env.example` as a reference and tweak it according to your environment.

```bash
cp .env.example .env
vi .env
```

10. Publish your local agent catalog to your Couchbase instance with `agentc publish`.
Your Couchbase instance details in the `.env` file will be used for authentication.
Again, this specific starter agent uses the `travel-sample` bucket.

```bash
agentc publish tool prompt --bucket travel-sample
```

11. Run your agent!

To start jupyter server, run the following command:

```bash
poetry run jupyter notebook
```

Once the server is running, open the `agent.ipynb` notebook and execute it to interact with your agent.
Loading

0 comments on commit 27c7d63

Please sign in to comment.