feat: Enable dual-GPU in RAG modelfile and add API key to upload script
This commit is contained in:
39
scripts/upload_to_openwebui.py
Normal file
39
scripts/upload_to_openwebui.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import requests
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
# Configuration
|
||||
OPENWEBUI_URL = "http://192.168.1.2:31028" # From AGENTS.full.md, the port is 31028
|
||||
API_KEY = "sk-609c9c4e941b487389a12b675742e288" # Placeholder
|
||||
SOURCE_DIRECTORY = "/mnt/storage.rushg.me/data/z5/rushg.me"
|
||||
|
||||
async def upload_files():
|
||||
"""
|
||||
Uploads all files from the source directory to OpenWebUI.
|
||||
"""
|
||||
headers = {"Authorization": f"Bearer {API_KEY}"}
|
||||
files_to_upload = []
|
||||
for root, _, files in os.walk(SOURCE_DIRECTORY):
|
||||
for file in files:
|
||||
files_to_upload.append(os.path.join(root, file))
|
||||
|
||||
for file_path in files_to_upload:
|
||||
try:
|
||||
with open(file_path, "rb") as f:
|
||||
files = {"file": (os.path.basename(file_path), f)}
|
||||
response = requests.post(f"{OPENWEBUI_URL}/api/v1/files", headers=headers, files=files)
|
||||
response.raise_for_status()
|
||||
print(f"Successfully uploaded {file_path}")
|
||||
except Exception as e:
|
||||
print(f"Failed to upload {file_path}: {e}")
|
||||
|
||||
async def main():
|
||||
print("This script requires an OpenWebUI API key.")
|
||||
# I will need the user to provide this.
|
||||
# For now, I will not run this script, but I'm creating it as part of the plan.
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
# asyncio.run(main())
|
||||
pass
|
||||
Reference in New Issue
Block a user