cianfhoghlaim/cianchosaint / .agents/skills/cocoindex
cocoindex
Verified| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 35.4 KB |
| references/api_reference.md | markdown | 11.0 KB |
| references/baml-extraction.md | markdown | 4.4 KB |
| references/cocoindex-api-research.md | markdown | 8.5 KB |
| references/connectors.md | markdown | 13.1 KB |
| references/fastapi-server.md | markdown | 2.3 KB |
| references/knowledge-graph-build.md | markdown | 2.8 KB |
| references/live-updates.md | markdown | 2.2 KB |
| references/multimodal-image-search.md | markdown | 1.7 KB |
| references/patterns.md | markdown | 13.6 KB |
| references/rust-port.md | markdown | 1.4 KB |
| references/setup_database.md | markdown | 4.4 KB |
| references/setup_project.md | markdown | 2.4 KB |
| references/v0-to-v1-migration.md | markdown | 7.0 KB |
references/fastapi-server.md
View on GitHub# FastAPI Server + CocoIndex v1 App
The canonical pattern for a CocoIndex v1 App that exposes a query
endpoint over HTTP. The CocoIndex app runs in live mode in the
background; the FastAPI server serves queries on top.
## Pattern
```python
# main.py
import asyncio
import pathlib
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import cocoindex as coco
from cocoindex.connectors import localfs, lancedb
# ... (CocoIndex app defined as in SKILL.md Step 4)
# 1. Start the CocoIndex app in live mode in a background task
@asynccontextmanager
async def lifespan(app: FastAPI):
coco.init()
app_main_task = asyncio.create_task(app_main_flow.update_async(...)) # pseudo
yield
app_main_task.cancel()
app = FastAPI(lifespan=lifespan)
class Query(BaseModel):
text: str
top_k: int = 5
class Hit(BaseModel):
filename: str
text: str
score: float
@app.post("/search", response_model=list[Hit])
async def search(query: Query) -> list[Hit]:
# Embed the query
embedder = await coco.use_context(EMBEDDER)
query_vec = await embedder.embed(query.text)
# Open the LanceDB table and search
conn = await coco.use_context(LANCE_DB)
table = await conn.open_table("my_table")
results = await (await table.search(query_vec, vector_column_name="embedding")).limit(query.top_k).to_list()
return [
Hit(filename=r["filename"], text=r["text"], score=1.0 - r["_distance"])
for r in results
]
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
```
## Cianfhoghlaim examples
- `cocoindex/image_search/pipeline.py` (deleted
with the docs but the pattern is the same) — CLIP embeddings +
Qdrant + FastAPI
- `cocoindex/image_search_colpali/pipeline.py` —
ColPali multi-vector + Qdrant MaxSim + FastAPI
- `agents/api/_cianfhoghlaim_api/routes/search.py` — the Cianfhoghlaim `/search/semantic`
endpoint (FastAPI route that hits the v1 leabharlann embeddings)
## Deployment
The FastAPI server + CocoIndex app can be deployed via:
- Docker (recommended; the `agents/api/_cianfhoghlaim_api` ships a `Dockerfile`)
- `dagster-modal` (the Dagster integration that runs the code on
Modal — see the `dagster` skill)
- Plain `uvicorn main:app` for local dev
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |