You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert

4
+
CocoIndex provides built-in support for code base chunking, using Tree-sitter to keep syntax boundary. In this example, we will build real-time index for codebase using CocoIndex.
4
5
5
-
In this example, we will build an embedding index for a codebase using CocoIndex. CocoIndex provides built-in support for code base chunking, with native Tree-sitter support. [Tree-sitter](https://en.wikipedia.org/wiki/Tree-sitter_%28parser_generator%29) is a parser generator tool and an incremental parsing library, it is available in Rust 🦀 - [GitHub](https://github.com/tree-sitter/tree-sitter). CocoIndex has built-in Rust integration with Tree-sitter to efficiently parse code and extract syntax trees for various programming languages.
6
+
We appreciate a star ⭐ at [CocoIndex Github](https://github.com/cocoindex-io/cocoindex) if this is helpful.
6
7
8
+

9
+
10
+
[Tree-sitter](https://en.wikipedia.org/wiki/Tree-sitter_%28parser_generator%29) is a parser generator tool and an incremental parsing library. It is available in Rust 🦀 - [GitHub](https://github.com/tree-sitter/tree-sitter). CocoIndex has built-in Rust integration with Tree-sitter to efficiently parse code and extract syntax trees for various programming languages. Check out the list of supported languages [here](https://cocoindex.io/docs/ops/functions#splitrecursively) - in the `language` section.
7
11
8
-
Please give [Cocoindex on Github](https://github.com/cocoindex-io/cocoindex) a star to support us if you like our work. Thank you so much with a warm coconut hug 🥥🤗. [](https://github.com/cocoindex-io/cocoindex)
9
12
10
13
## Tutorials
11
-
- Blog with step by step tutorial [here](https://cocoindex.io/blogs/index-code-base-for-rag).
12
-
- Video walkthrough [here](https://youtu.be/G3WstvhHO24?si=Bnxu67Ax5Lv8b-J2)
14
+
- Step by step tutorial - Check out the [blog](https://cocoindex.io/blogs/index-code-base-for-rag).
15
+
- Video tutorial - [Youtube](https://youtu.be/G3WstvhHO24?si=Bnxu67Ax5Lv8b-J2).
16
+
17
+
## Steps
18
+
19
+
### Indexing Flow
20
+
<palign='center'>
21
+
<imgwidth="434"alt="Screenshot 2025-05-19 at 10 14 36 PM"src="https://github.com/user-attachments/assets/3a506034-698f-480a-b653-22184dae4e14" />
22
+
</p>
23
+
24
+
1. We will ingest CocoIndex codebase.
25
+
2. For each file, perform chunking (Tree-sitter) and then embedding.
26
+
3. We will save the embeddings and the metadata in Postgres with PGVector.
27
+
28
+
### Query:
29
+
We will match against user-provided text by a SQL query, reusing the embedding operation in the indexing flow.
13
30
14
31
15
32
## Prerequisite
16
33
[Install Postgres](https://cocoindex.io/docs/getting_started/installation#-install-postgres) if you don't have one.
17
34
18
35
## Run
19
36
20
-
Install dependencies:
21
-
```bash
22
-
pip install -e .
23
-
```
24
-
25
-
Setup:
37
+
- Install dependencies:
38
+
```bash
39
+
pip install -e .
40
+
```
26
41
27
-
```bash
28
-
python main.py cocoindex setup
29
-
```
42
+
- Setup:
30
43
31
-
Update index:
44
+
```bash
45
+
python main.py cocoindex setup
46
+
```
32
47
33
-
```bash
34
-
python main.py cocoindex update
35
-
```
48
+
- Update index:
49
+
50
+
```bash
51
+
python main.py cocoindex update
52
+
```
36
53
37
-
Run:
54
+
-Run:
38
55
39
-
```bash
40
-
python main.py
41
-
```
56
+
```bash
57
+
python main.py
58
+
```
42
59
43
60
## CocoInsight
44
-
CocoInsight is in Early Access now (Free) 😊 You found us! A quick 3 minute video tutorial about CocoInsight: [Watch on YouTube](https://youtu.be/ZnmyoHslBSc?si=pPLXWALztkA710r9).
45
-
46
-
Run CocoInsight to understand your RAG data pipeline:
61
+
I used CocoInsight (Free beta now) to troubleshoot the index generation and understand the data lineage of the pipeline.
62
+
It just connects to your local CocoIndex server, with Zero pipeline data retention. Run the following command to start CocoInsight:
47
63
48
64
```
49
65
python main.py cocoindex server -ci
50
66
```
51
67
52
68
Then open the CocoInsight UI at [https://cocoindex.io/cocoinsight](https://cocoindex.io/cocoinsight).
0 commit comments