Add LICENSE and README and .gitignore files
This commit is contained in:
parent
db84346849
commit
286b80770e
57
.gitignore
vendored
Normal file
57
.gitignore
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
.env
|
||||||
|
|
||||||
|
# IDE specific files
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pytest
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Local development settings
|
||||||
|
*.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Log files
|
||||||
|
*.log
|
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025
|
||||||
|
|
||||||
|
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.
|
87
README.md
Normal file
87
README.md
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# 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:
|
||||||
|
```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
|
||||||
|
|
||||||
|
Feel free to open issues or submit pull requests to improve this tool.
|
Loading…
x
Reference in New Issue
Block a user