Skip to content

Commit

Permalink
Add repository setup and documentation
Browse files Browse the repository at this point in the history
- Add GitHub Actions workflows for testing and publishing
- Add MIT LICENSE
- Expand README with:
  - Status badges
  - Detailed features and installation
  - Usage examples with output
  - Development guidelines
  - Project structure
  - Integration information
  • Loading branch information
ErikBjare committed Nov 15, 2024
1 parent 7c89453 commit 828692d
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 8 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run pytest

- name: Build and publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
poetry build
poetry publish
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run pytest --cov=gptme_rag --cov-report=xml

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Erik Bjäreholt and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
106 changes: 98 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,42 @@

RAG (Retrieval-Augmented Generation) implementation for gptme context management.

<p align="center">
<a href="https://github.com/ErikBjare/gptme-rag/actions/workflows/test.yml">
<img src="https://github.com/ErikBjare/gptme-rag/actions/workflows/test.yml/badge.svg" alt="Tests" />
</a>
<a href="https://pypi.org/project/gptme-rag/">
<img src="https://img.shields.io/pypi/v/gptme-rag" alt="PyPI version" />
</a>
<a href="https://github.com/ErikBjare/gptme-rag/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/ErikBjare/gptme-rag" alt="License" />
</a>
</p>

## Features

- Document indexing with ChromaDB
- Semantic search with embeddings
- Context assembly with token management
- CLI interface for testing and development
- 📚 Document indexing with ChromaDB
- Fast and efficient vector storage
- Semantic search capabilities
- Persistent storage
- 🔍 Semantic search with embeddings
- Relevance scoring
- Token-aware context assembly
- Clean output formatting
- 🛠️ CLI interface for testing and development
- Index management
- Search functionality
- Context assembly

## Installation

```bash
# Clone the repository
# From PyPI (coming soon)
pip install gptme-rag

# From source
git clone https://github.com/ErikBjare/gptme-rag.git
cd gptme-rag

# Install with poetry
poetry install
```

Expand All @@ -25,21 +46,90 @@ poetry install
### Indexing Documents

```bash
# Index markdown files in a directory
poetry run python -m gptme_rag index /path/to/documents --pattern "**/*.md"

# Index with custom persist directory
poetry run python -m gptme_rag index /path/to/documents --persist-dir ./index
```

### Searching

```bash
poetry run python -m gptme_rag search "your query here" --n-results 5
# Basic search
poetry run python -m gptme_rag search "your query here"

# Advanced search with options
poetry run python -m gptme_rag search "your query" \
--n-results 5 \
--persist-dir ./index \
--max-tokens 4000 \
--show-context
```

### Example Output
```plaintext
Most Relevant Documents:
1. ARCHITECTURE.md (relevance: 0.82)
The task system is designed to help track and manage work effectively across sessions. Components include task registry, status tracking, and journal integration.
2. TASKS.md (relevance: 0.75)
Active tasks and their current status. Includes task categories, status indicators, and progress tracking.
3. docs/workflow.md (relevance: 0.65)
Documentation about workflow integration and best practices for task management.
Full Context:
Total tokens: 1250
Documents included: 3
Truncated: False
```

## Development

### Running Tests

```bash
# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov=gptme_rag
```

### Project Structure

```plaintext
gptme_rag/
├── __init__.py
├── cli.py # CLI interface
├── indexing/ # Document indexing
│ ├── document.py # Document model
│ └── indexer.py # ChromaDB integration
├── query/ # Search functionality
│ └── context_assembler.py # Context assembly
└── utils/ # Utility functions
```

### Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Run tests and linting
6. Submit a pull request

## Integration with gptme

This package is designed to integrate with [gptme](https://github.com/ErikBjare/gptme) as a plugin, providing:

- Automatic context enhancement
- Semantic search across project files
- Knowledge base integration
- Smart context assembly

## License

MIT License. See [LICENSE](LICENSE) for details.

0 comments on commit 828692d

Please sign in to comment.