Skip to content

ryan-hansen/agent-vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LanceDB FastAPI Service

A FastAPI service that provides an API for a LanceDB vector database running in a Docker container.

Features

  • Create and manage LanceDB tables
  • Add, search, and delete vector data
  • Filter search results by metadata
  • Containerized with Docker for easy deployment

Requirements

  • Docker
  • Docker Compose

Getting Started

Running the Service

  1. Clone this repository:

    git clone <repository-url>
    cd lancedb
  2. Start the service using Docker Compose:

    docker-compose up -d
  3. The API will be available at http://localhost:8002

API Endpoints

  • GET /api/tables - List all tables
  • POST /api/tables - Create a new table
  • POST /api/vectors - Add vectors to a table
  • POST /api/search/{table_name} - Search for similar vectors
  • DELETE /api/vectors - Delete vectors from a table
  • GET /api/tables/{table_name}/info - Get information about a table

Example Usage

Create a Table

curl -X POST "http://localhost:8002/api/tables" \
  -H "Content-Type: application/json" \
  -d '{"table_name": "my_vectors", "vector_dimension": 384}'

Add Vectors

curl -X POST "http://localhost:8002/api/vectors" \
  -H "Content-Type: application/json" \
  -d '{
    "table_name": "my_vectors",
    "vectors": [
      {
        "id": "vec1",
        "vector": [0.1, 0.2, 0.3, ...],
        "metadata": {"category": "example", "source": "test"}
      }
    ]
  }'

Search Vectors

curl -X POST "http://localhost:8002/api/search/my_vectors" \
  -H "Content-Type: application/json" \
  -d '{
    "vector": [0.1, 0.2, 0.3, ...],
    "metadata_filter": {"category": "example"},
    "limit": 5
  }'

Delete Vectors

curl -X DELETE "http://localhost:8002/api/vectors" \
  -H "Content-Type: application/json" \
  -d '{
    "table_name": "my_vectors",
    "ids": ["vec1"]
  }'

Development

Project Structure

.
├── app/
│   ├── api/           # API endpoints
│   ├── db/            # Database client
│   ├── models/        # Data models
│   └── main.py        # FastAPI application
├── data/              # LanceDB data (mounted volume)
├── Dockerfile
├── docker-compose.yml
└── requirements.txt

Adding Dependencies

If you need to add new dependencies, update the requirements.txt file and rebuild the Docker image:

docker-compose build
docker-compose up -d

License

MIT License

About

Vector DB service for agentic AI pipeline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors