2.4 KiB
2.4 KiB
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:
- Creating a new knowledge base in OpenWebUI
- Scanning your repository for supported file types
- Uploading relevant files to OpenWebUI
- Adding the uploaded files to the knowledge base
Supported File Types
The utility processes the following file types:
- Text files (
.txt
) - Markdown files (
.md
) - Python files (
.py
) - JavaScript files (
.js
) - 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
) - 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
- Clone this repository
- Install required dependencies:
pip install requests
Usage
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
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.
Contributing
Feel free to open issues or submit pull requests to improve this tool.