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