-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
3,760 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python: [ '3.10', '3.11', '3.12' ] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Setup PDM | ||
uses: pdm-project/setup-pdm@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
cache: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt update && sudo apt install --yes libgl1-mesa-dev | ||
pdm lock | ||
pdm install --dev | ||
- name: Test with pytest | ||
run: | | ||
pdm run make test-cicd | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4.0.2 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: sysid/prepembd | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python: [ '3.10', '3.11', '3.12' ] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Setup PDM | ||
uses: pdm-project/setup-pdm@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
cache: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
pdm lock | ||
pdm install --dev | ||
# - name: mypy | ||
# run: | | ||
# pdm run mypy --python-version=${{ matrix.python }} src/ | ||
|
||
- name: lint | ||
run: | | ||
pdm run make lint | ||
- name: format | ||
run: | | ||
pdm run make format-check | ||
- name: isort | ||
run: | | ||
pdm run isort . --check --diff |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
# prepembd | ||
|
||
[![PyPi](https://img.shields.io/pypi/v/inka2)](https://pypi.org/project/prepembd) | ||
[![Tests CI](https://img.shields.io/github/actions/workflow/status/sysid/prepembd/test.yml?branch=main)](https://github.com/sysid/inka2/actions/workflows/prepembd.yml) | ||
[![Codecov](https://codecov.io/gh/sysid/prepembd/branch/main/graph/badge.svg?token=8IL9MN4FK5)](https://codecov.io/gh/sysid/prepembd) | ||
|
||
|
||
## Installation | ||
|
||
Install **prepembd**: | ||
|
||
```shell | ||
python3 -m pip install prepembd --upgrade | ||
``` | ||
|
||
### Requirements | ||
|
||
- [Python](https://www.python.org/) >= 3.10 | ||
|
||
## Why | ||
|
||
I've been using markdown now for a long time to take notes in every possible scenario. I even manage my Anki cards with markdown ([inka2](https://github.com/sysid/inka2)) so finding relevant information again is paramount. | ||
With the advent of semantic search via Embeddings search became so much more powerfull. However, to create the | ||
embeddings out of markdown the files have to be prepared in order to reduce noice and create the correct chunk sizes. | ||
|
||
This Python script automates the process and creates a json representation of all the markdown files which then can be fed into an embedding model. It is basically just a thin wrapper aroung LangChain combined with some bespoke filter to eliminated noise. | ||
|
||
|
||
## Usage | ||
```bash | ||
prepembd tokenize <directory> | tee -a output.ndjson | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="10" time="4.518" timestamp="2024-03-17T16:24:12.587130" hostname="LMUCM1032419"><testcase classname="tests.lib.test_helper" name="test_remove_excessive_dots" time="0.002" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[This is a test.\nThis is another line.-This is a test.\nThis is another line.]" time="0.001" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[> This is a quoted line.\nThis is not quoted.-This is a quoted line.\nThis is not quoted.]" time="0.000" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[> Quote1.\n> Quote2.-Quote1.\nQuote2.]" time="0.000" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[-]" time="0.000" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[Single line with > quote-Single line with > quote]" time="0.000" /><testcase classname="tests.lib.test_helper" name="test_strip_quote_prefixes[>No space after quote mark->No space after quote mark]" time="0.000" /><testcase classname="tests.lib.test_path" name="test_scan_directory" time="0.020" /><testcase classname="tests.test_tokenize.TestTokenize" name="test_tokenize_tiktoken" time="0.246" /><testcase classname="tests.test_tokenize.TestTokenize" name="test_tokenize_help" time="0.016" /></testsuite></testsuites> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.