Deep link to markdown entries by line number in uri

Use url fragment schema for deep link URIs, borrowing from URL/PDF
schemas. E.g file:///path/to/file.txt#line=<line_no>&#page=<page_no>

Compute line number during (recursive) markdown entry chunking.

Test line number in URI maps to line number of chunk in actual md file.

This deeplink URI with line number is passed to llm as context to
better combine with line range based view file tool.

Grep tool already passed matching line number. This change passes
line number in URIs of markdown entries matched by the semantic search
tool.
This commit is contained in:
Debanjum
2025-07-03 18:34:34 -07:00
parent dcfa4288c4
commit 5010623a0a
3 changed files with 135 additions and 9 deletions

39
tests/data/markdown/main_readme.md vendored Normal file
View File

@@ -0,0 +1,39 @@
# Main Readme
> Allow natural language search, chat with your documents using transformer based models
This is a test markdown file with multiple, nested child entries.
## Dependencies
- Python3
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html#latest-miniconda-installer-links)
## Installation
```bash
pip install khoj
```
## Run
Load ML model, generate embeddings and expose API to query specified org-mode files
```shell
python3 main.py --input-files ~/Notes/Schedule.org ~/Notes/Incoming.org --verbose
```
## Use
### **Khoj via API**
- Query: `GET` [http://localhost:42110/api/search?q="What is the meaning of life"](http://localhost:42110/api/search?q=%22what%20is%20the%20meaning%20of%20life%22)
- Update Index: `GET` [http://localhost:42110/api/update](http://localhost:42110/api/update)
- [Khoj API Docs](http://localhost:42110/docs)
### *Khoj via Web*
- Open browser to http://localhost:42110
- Enter query in search box
## Acknowledgments
- [MiniLM Model](https://huggingface.co/sentence-transformers/multi-qa-MiniLM-L6-cos-v1) for Asymmetric Text Search. See (SBert Documentation)[https://www.sbert.net/examples/applications/retrieve_rerank/README.html]
- [OpenAI CLIP Model](https://github.com/openai/CLIP) for Image Search. See [SBert Documentation](https://www.sbert.net/examples/applications/image-search/README.html)