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)
  • Markdown files (.md)
  • Python files (.py)
  • JavaScript files (.js)
  • HTML files (.html)
  • CSS files (.css)
  • JSON files (.json)
  • YAML files (.yaml, .yml)
  • Shell scripts (.sh)
  • Batch files (.bat)
  • 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:
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.

Description
Upload local repo to OpenWebUI KB
Readme MIT 38 KiB
Languages
Python 100%