git-to-kb/README.md

92 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

# git-to-kb
A Python utility to create a knowledge base from a Git repository by importing files into OpenWebUI.
## Description
`git-to-kb` is a command-line tool that helps you create a knowledge base from your local Git repository by:
1. Creating a new knowledge base in OpenWebUI
2. Scanning your repository for supported file types
3. Uploading relevant files to OpenWebUI
4. Adding the uploaded files to the knowledge base
## Supported File Types
The utility processes the following file types:
- Text files (`.txt`)
2025-02-17 09:50:51 -08:00
- Markdown files (`.md`)
- Python files (`.py`)
- JavaScript files (`.js`)
2025-02-17 09:50:51 -08:00
- TypeScript files (`.ts`)
- TypeScript React files (`.tsx`)
- HTML files (`.html`)
- CSS files (`.css`)
- JSON files (`.json`)
- YAML files (`.yaml`, `.yml`)
- Shell scripts (`.sh`)
- Batch files (`.bat`)
2025-02-17 09:50:51 -08:00
- Jinja2 templates (`.j2`)
- Template files (`.tpl`)
- Dockerfiles
- LICENSE files
## Prerequisites
- Python 3.x
- `requests` library (`pip install requests`)
- Access to an OpenWebUI instance
- OpenWebUI API token
## Installation
1. Clone this repository
2. Install required dependencies:
```bash
pip install requests
```
## Usage
```bash
python git-to-kb.py --token YOUR_API_TOKEN \
--base-url OPENWEB_URL \
--repo-path /path/to/repo \
--kb-name "Knowledge Base Name" \
[--kb-purpose "Optional description"]
```
### Arguments
- `--token, -t`: Your OpenWebUI API token (required)
- `--base-url, -u`: Base URL of your OpenWebUI instance (e.g., http://localhost:3000) (required)
- `--repo-path, -r`: Path to the local git repository (required)
- `--kb-name, -n`: Name for the knowledge base (required)
- `--kb-purpose, -p`: Purpose description for the knowledge base (optional)
## Example
```bash
python git-to-kb.py -t "api_token_123" \
-u "http://localhost:3000" \
-r "/path/to/my/repo" \
-n "My Project KB" \
-p "Documentation for My Project"
```
## Error Handling
The script will:
- Skip the `.git` directory
- Print error messages for failed file uploads
- Continue processing remaining files if an error occurs
- Display a summary of processed files upon completion
## License
This project is licensed under the terms of the MIT [LICENSE](LICENSE).
## Contributing
2025-02-17 09:50:51 -08:00
Feel free to open issues or submit pull requests to improve this tool.