Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
### Claude
```bash
claude mcp add cocoindex-code \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

### Codex
```bash
codex mcp add cocoindex-code \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

### OpenCode
Expand Down Expand Up @@ -122,7 +122,7 @@ Set `COCOINDEX_CODE_EMBEDDING_MODEL` to any [LiteLLM-supported model](https://do
```bash
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=ollama/nomic-embed-text \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

Set `OLLAMA_API_BASE` if your Ollama server is not at `http://localhost:11434`.
Expand All @@ -136,7 +136,7 @@ Set `OLLAMA_API_BASE` if your Ollama server is not at `http://localhost:11434`.
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=text-embedding-3-small \
-e OPENAI_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -150,7 +150,7 @@ claude mcp add cocoindex-code \
-e AZURE_API_KEY=your-api-key \
-e AZURE_API_BASE=https://your-resource.openai.azure.com \
-e AZURE_API_VERSION=2024-06-01 \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -162,7 +162,7 @@ claude mcp add cocoindex-code \
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=gemini/text-embedding-004 \
-e GEMINI_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -174,7 +174,7 @@ claude mcp add cocoindex-code \
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=mistral/mistral-embed \
-e MISTRAL_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -186,7 +186,7 @@ claude mcp add cocoindex-code \
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=voyage/voyage-code-3 \
-e VOYAGE_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -198,7 +198,7 @@ claude mcp add cocoindex-code \
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=cohere/embed-english-v3.0 \
-e COHERE_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -212,7 +212,7 @@ claude mcp add cocoindex-code \
-e AWS_ACCESS_KEY_ID=your-access-key \
-e AWS_SECRET_ACCESS_KEY=your-secret-key \
-e AWS_REGION_NAME=us-east-1 \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand All @@ -224,7 +224,7 @@ claude mcp add cocoindex-code \
claude mcp add cocoindex-code \
-e COCOINDEX_CODE_EMBEDDING_MODEL=nebius/BAAI/bge-en-icl \
-e NEBIUS_API_KEY=your-api-key \
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a18" cocoindex-code@latest
-- uvx --prerelease=explicit --with "cocoindex>=1.0.0a22" cocoindex-code@latest
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [

dependencies = [
"mcp>=1.0.0",
"cocoindex[litellm]>=1.0.0a18,<=1.0.0a19",
"cocoindex[litellm]==1.0.0a22",
"sentence-transformers>=2.2.0",
"sqlite-vec>=0.1.0",
"pydantic>=2.0.0",
Expand Down
18 changes: 9 additions & 9 deletions src/cocoindex_code/indexer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""CocoIndex app for indexing codebases."""

import cocoindex.asyncio as coco_aio
import cocoindex as coco
from cocoindex.connectors import localfs, sqlite
from cocoindex.ops.text import RecursiveSplitter, detect_code_language
from cocoindex.resources.chunk import Chunk
Expand Down Expand Up @@ -63,7 +63,7 @@
splitter = RecursiveSplitter()


@coco_aio.function(memo=True)
@coco.fn(memo=True)
async def process_file(
file: localfs.AsyncFile,
table: sqlite.TableTarget[CodeChunk],
Expand Down Expand Up @@ -108,13 +108,13 @@ async def process(
)
)

await coco_aio.map(process, chunks)
await coco.map(process, chunks)


@coco_aio.function
@coco.fn
async def app_main() -> None:
"""Main indexing function - walks files and processes each."""
db = coco_aio.use_context(SQLITE_DB)
db = coco.use_context(SQLITE_DB)

# Declare the table target for storing embeddings
table = await db.mount_table_target(
Expand All @@ -136,12 +136,12 @@ async def app_main() -> None:
)

# Process each file
with coco_aio.component_subpath(coco_aio.Symbol("process_file")):
await coco_aio.mount_each(process_file, files.items(), table)
with coco.component_subpath(coco.Symbol("process_file")):
await coco.mount_each(process_file, files.items(), table)


# Create the app
app = coco_aio.App(
coco_aio.AppConfig(name="CocoIndexCode"),
app = coco.App(
coco.AppConfig(name="CocoIndexCode"),
app_main,
)
3 changes: 2 additions & 1 deletion src/cocoindex_code/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ async def query_codebase(
)

# Get the database connection from CocoIndex environment
db = coco.default_env().get_context(SQLITE_DB)
coco_env = await coco.default_env()
db = coco_env.get_context(SQLITE_DB)

# Generate query embedding
query_embedding = await embedder.embed(query)
Expand Down
20 changes: 10 additions & 10 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.