switch to AI Horde Worker

This commit is contained in:
db0
2023-08-21 15:52:17 +02:00
parent 8daa2f1adc
commit 45661ddc75
2 changed files with 22 additions and 33 deletions

4
.gitmodules vendored
View File

@@ -1,6 +1,6 @@
[submodule "KoboldAI-Horde"]
path = KoboldAI-Horde
url = https://github.com/db0/KoboldAI-Horde-Bridge
url = https://github.com/Haidra-Org/AI-Horde-Worker
[submodule "KoboldAI-Horde-Bridge"]
path = KoboldAI-Horde-Bridge
url = https://github.com/db0/KoboldAI-Horde-Bridge
url = https://github.com/Haidra-Org/AI-Horde-Worker

View File

@@ -1350,39 +1350,28 @@ class system_settings(settings):
self._koboldai_var.calc_ai_text()
if name == 'horde_share':
if self.on_colab == False:
if os.path.exists("./KoboldAI-Horde-Bridge"):
if value == True:
if self.on_colab is True:
return
if not os.path.exists("./KoboldAI-Horde-Bridge"):
return
if value is True:
if self._horde_pid is None:
logger.info("Starting Horde bridge")
bridge = importlib.import_module("KoboldAI-Horde-Bridge.bridge")
self._horde_pid = bridge.kai_bridge()
try:
bridge_cd = importlib.import_module("KoboldAI-Horde-Bridge.clientData")
cluster_url = bridge_cd.cluster_url
kai_name = bridge_cd.kai_name
if kai_name == "My Awesome Instance":
kai_name = f"KoboldAI UI Instance #{random.randint(-100000000, 100000000)}"
api_key = bridge_cd.api_key
priority_usernames = bridge_cd.priority_usernames
except:
cluster_url = "https://horde.koboldai.net"
kai_name = self._koboldai_var.horde_worker_name
if kai_name == "My Awesome Instance":
kai_name = f"KoboldAI UI Instance #{random.randint(-100000000, 100000000)}"
api_key = self._koboldai_var.horde_api_key
priority_usernames = []
# Always use the local URL & port
kai_url = f'http://127.0.0.1:{self.port}'
logger.info(f"Name: {kai_name} on {kai_url}")
threading.Thread(target=self._horde_pid.bridge, args=(1, api_key, kai_name, kai_url, cluster_url, priority_usernames)).run()
bd_module = importlib.import_module("KoboldAI-Horde-Bridge.worker.bridge_data.scribe")
bridge_data = bd_module.KoboldAIBridgeData()
bridge_data.reload_data()
bridge_data.kai_url = f'http://127.0.0.1:{self.port}'
logger.info(f"Name: {bridge_data.worker_name} on {bridge_data.kai_url}")
worker_module = importlib.import_module("KoboldAI-Horde-Bridge.worker.workers.scribe")
self._horde_pid = worker_module.ScribeWorker(bridge_data)
threading.Thread(target=self._horde_pid.start).run()
else:
if self._horde_pid is not None:
logger.info("Killing Horde bridge")
self._horde_pid.stop()
self._horde_pid = None
class KoboldStoryRegister(object):
def __init__(self, socketio, story_settings, koboldai_vars, tokenizer=None, sequence=[]):
self._socketio = socketio