|
@ -16,8 +16,8 @@ import json |
|
|
|
|
|
|
|
|
from .helpers import Event |
|
|
from .helpers import Event |
|
|
from .chatlog import BotChatHistory |
|
|
from .chatlog import BotChatHistory |
|
|
ai = importlib.import_module("matrix_pygmalion_bot.ai.runpod_pygmalion") |
|
|
image_ai = importlib.import_module("matrix_pygmalion_bot.ai.runpod_pygmalion") |
|
|
ai = importlib.import_module("matrix_pygmalion_bot.ai.koboldcpp") |
|
|
text_ai = importlib.import_module("matrix_pygmalion_bot.ai.koboldcpp") |
|
|
#ai = importlib.import_module("matrix_pygmalion_bot.ai.stablehorde") |
|
|
#ai = importlib.import_module("matrix_pygmalion_bot.ai.stablehorde") |
|
|
#from .llama_cpp import generate, get_full_prompt, get_full_prompt_chat_style |
|
|
#from .llama_cpp import generate, get_full_prompt, get_full_prompt_chat_style |
|
|
#from .runpod_pygmalion import generate_sync, get_full_prompt |
|
|
#from .runpod_pygmalion import generate_sync, get_full_prompt |
|
@ -114,30 +114,30 @@ class Callbacks(object): |
|
|
typing = lambda : self.client.room_typing(room.room_id, True, 15000) |
|
|
typing = lambda : self.client.room_typing(room.room_id, True, 15000) |
|
|
if self.bot.service == "runpod": |
|
|
if self.bot.service == "runpod": |
|
|
if num == 1: |
|
|
if num == 1: |
|
|
output = await ai.generate_image1(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image1(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 2: |
|
|
elif num == 2: |
|
|
output = await ai.generate_image2(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image2(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 3: |
|
|
elif num == 3: |
|
|
output = await ai.generate_image3(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image3(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 4: |
|
|
elif num == 4: |
|
|
output = await ai.generate_image4(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image4(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 5: |
|
|
elif num == 5: |
|
|
output = await ai.generate_image5(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image5(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 6: |
|
|
elif num == 6: |
|
|
output = await ai.generate_image6(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image6(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 7: |
|
|
elif num == 7: |
|
|
output = await ai.generate_image7(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image7(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
elif num == 8: |
|
|
elif num == 8: |
|
|
output = await ai.generate_image8(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
output = await image_ai.generate_image8(prompt, negative_prompt, self.bot.runpod_api_key, typing) |
|
|
else: |
|
|
else: |
|
|
raise ValueError('no image generator with that number') |
|
|
raise ValueError('no image generator with that number') |
|
|
elif self.bot.service == "stablehorde": |
|
|
elif self.bot.service == "stablehorde": |
|
|
if num == 1: |
|
|
if num == 1: |
|
|
output = await ai.generate_image1(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
output = await image_ai.generate_image1(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
elif num == 2: |
|
|
elif num == 2: |
|
|
output = await ai.generate_image2(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
output = await image_ai.generate_image2(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
elif num == 3: |
|
|
elif num == 3: |
|
|
output = await ai.generate_image3(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
output = await image_ai.generate_image3(prompt, negative_prompt, self.bot.stablehorde_api_key, typing) |
|
|
else: |
|
|
else: |
|
|
raise ValueError('no image generator with that number') |
|
|
raise ValueError('no image generator with that number') |
|
|
else: |
|
|
else: |
|
@ -216,8 +216,8 @@ class Callbacks(object): |
|
|
# send, mail, drop, snap picture, photo, image, portrait |
|
|
# send, mail, drop, snap picture, photo, image, portrait |
|
|
pass |
|
|
pass |
|
|
|
|
|
|
|
|
full_prompt = await ai.get_full_prompt(chat_message.getTranslation("en"), self.bot, self.bot.chat_history.room(room.display_name)) |
|
|
full_prompt = await text_ai.get_full_prompt(chat_message.getTranslation("en"), self.bot, self.bot.chat_history.room(room.display_name)) |
|
|
num_tokens = await ai.num_tokens(full_prompt) |
|
|
num_tokens = await text_ai.num_tokens(full_prompt) |
|
|
logger.debug(full_prompt) |
|
|
logger.debug(full_prompt) |
|
|
logger.debug(f"Prompt has " + str(num_tokens) + " tokens") |
|
|
logger.debug(f"Prompt has " + str(num_tokens) + " tokens") |
|
|
# answer = "" |
|
|
# answer = "" |
|
@ -237,7 +237,7 @@ class Callbacks(object): |
|
|
# print("") |
|
|
# print("") |
|
|
try: |
|
|
try: |
|
|
typing = lambda : self.client.room_typing(room.room_id, True, 15000) |
|
|
typing = lambda : self.client.room_typing(room.room_id, True, 15000) |
|
|
answer = await ai.generate_sync(full_prompt, self.bot.runpod_api_key, self.bot, typing, api_endpoint) |
|
|
answer = await text_ai.generate_sync(full_prompt, self.bot.runpod_api_key, self.bot, typing, api_endpoint) |
|
|
answer = answer.strip() |
|
|
answer = answer.strip() |
|
|
await self.client.room_typing(room.room_id, False) |
|
|
await self.client.room_typing(room.room_id, False) |
|
|
if not (self.bot.translate is None): |
|
|
if not (self.bot.translate is None): |
|
|