Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.29 KB

File metadata and controls

51 lines (36 loc) · 1.29 KB

1 Install the CLI

python -m pip install --upgrade pip
pip install redis-context-retriever

Add C:\Users\<user>\AppData\Roaming\Python\Python<version>\Scripts to the PATH variable

2 Authenticate

ctxctl auth login <keyname> --type admin

Then enter your admin key retrieved from Redis Cloud

3 Define your model (save as ./models.py)

cat <<'PY' > models.py
from context_surfaces.context_model import ContextField, ContextModel

class Item(ContextModel):
    __redis_key_template__ = "item:{id}"
    id: int = ContextField(description="Item ID", is_key_component=True)
    title: str = ContextField(description="Title", index="text")
    price: float = ContextField(description="Price", index="numeric", sortable=True)
PY

4 Create a Context Retriever service with a Redis data source

ctxctl surface create --name "My Surface" --models ./models.py --redis-addr "redis.example.com:6379" --redis-password "$REDIS_PASSWORD"

5 Create an agent key

ctxctl agent create --surface-id "<SURFACE_ID>" --name "My Agent"

6 List tools and run a sample query

ctxctl tools list --agent-key "<AGENT_KEY>"
ctxctl tools call search_item_by_text --agent-key "<AGENT_KEY>" --query "coffee"

Python SDK on PyPI