Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
blomqma committed Sep 24, 2024
1 parent efb8dca commit 866d513
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 64 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Configure Poetry
run: |
poetry config virtualenvs.create false
- name: Install Dependencies
run: poetry install --no-interaction --no-ansi

- name: Run Tests
run: pytest

- name: Lint with flake8
run: flake8

- name: Format with black
run: black --check .

- name: Sort imports with isort
run: isort --check-only .
22 changes: 0 additions & 22 deletions .github/workflows/lint.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ repos:
hooks:
- id: flake8
args: [--max-line-length=88, "--ignore=E203,W503"]
- repo: local
hooks:
- id: run-tests
name: Run Tests
entry: scripts/run_tests.sh
language: script
pass_filenames: false
75 changes: 35 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,60 @@
# Git Vector
# Git-Vector

## Overview
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

Git Vector is a Python tool that enhances the capabilities of OpenAI models by providing them with context from Git repositories. This allows for more informed and relevant interactions with the models, leveraging the rich history and content of your codebase.
**Git-Vector** is a command-line tool that allows developers to interact with their Git repositories using OpenAI models. It provides a conversational interface to help you understand and navigate your codebase by leveraging the full context of your repository.

## Features

- **Contextual Prompting**: Integrate Git repository context into prompts for OpenAI models.
- **Embeddings Cache**: Efficiently cache embeddings to speed up repeated queries.
- **Tracked File Retrieval**: Automatically retrieve tracked files from a Git repository.
- **Text File Detection**: Identify text files to ensure only relevant content is processed.
## Table of Contents

## Installation
- [Git-Vector](#git-vector)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [License](#license)
- [Author](#author)
- [Acknowledgments](#acknowledgments)

To install Git Vector, you'll need to have Python 3.12 or higher. You can install the project using Poetry:
## Features

```bash
poetry install
```
- **Conversational Interface**: Interactively ask questions about your codebase and receive detailed explanations.
- **Full Repository Context**: The tool indexes your entire Git repository to provide context-aware responses.
- **Caching Mechanism**: Embeddings are cached to improve performance on subsequent runs.
- **Customizable Models**: Supports different OpenAI models for both embeddings and chat completions.
- **Configurable Parameters**: Adjust maximum tokens for prompts and responses to suit your needs.

Alternatively, you can clone the repository and install the dependencies manually:
## Installation

```bash
git clone [email protected]:blomqma/git-vector.git
cd git-vector
pip install -r requirements.txt
pip install git-vector
```

## Usage

1. **Set Up Environment Variables**: Create a `.env` file in the root directory of your project and add your OpenAI API key:
1. **Set Up Environment Variables**:

Export your OpenAI API key as an environment variable (or use a `.env` file):

```
OPENAI_API_KEY=your_api_key_here
export OPENAI_API_KEY=your_api_key_here
```

2. **Run the Application**: Use the command line interface to interact with the tool. For example:
2. **Run the Application**:

```bash
python main.py
```
git-vector --repo-dir /path/to/your/git/repository
```

You can specify the directory of your Git repository as an argument.

## Development

To contribute to the development of Git Vector, you can set up your development environment using the following commands:

```bash
# Install development dependencies
poetry install --with dev

# Format code
poetry run black .
This will start the intera`tive CLI for the user to chat with the codebase.

# Check code style
poetry run flake8 .
## Configuration

# Run tests
poetry run pytest
```
- `--repo-dir`: (Required) The path to the Git repository.
- `--embedding-model`: The OpenAI model to use for embeddings (default: `text-embedding-3-small`).
- `--chat-model`: The OpenAI model to use for chat completions (default: `gpt-4o-mini`).
- `--max-prompt-tokens`: Maximum number of tokens for the prompt (default: `2000`).
- `--max-response-tokens`: Maximum number of tokens for the response (default: `500`).

## License

Expand Down
5 changes: 5 additions & 0 deletions git_vector/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__version__ = "0.1.0"

from .git_vector import main

__all__ = ["main"]
4 changes: 3 additions & 1 deletion main.py → git_vector/git_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ def main(
"""Main function to run the CLI tool."""
logger.info("Starting Codebase Assistant...")

cli_dir = os.path.dirname(os.path.abspath(__file__))
current_file_path = os.path.abspath(__file__)
current_dir = os.path.dirname(current_file_path)
cli_dir = os.path.dirname(current_dir)
cache_dir = os.path.join(cli_dir, "embeddings_cache")
os.makedirs(cache_dir, exist_ok=True)

Expand Down
Loading

0 comments on commit 866d513

Please sign in to comment.