Skip to content

Commit

Permalink
Huge upgrade, discussion system is now in lollms core
Browse files Browse the repository at this point in the history
  • Loading branch information
ParisNeo committed Feb 26, 2024
1 parent c453f90 commit 02e829b
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 1,498 deletions.
808 changes: 0 additions & 808 deletions api/db.py

This file was deleted.

4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_ip_addresses():
config.allowed_origins += config["host"]
else:
config.allowed_origins += get_ip_addresses()

sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=config.allowed_origins+[f"https://localhost:{config['port']}" if is_https else f"http://localhost:{config['port']}"], ping_timeout=1200, ping_interval=30) # Enable CORS for selected origins

LOLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, args=args, sio=sio)
Expand All @@ -109,7 +109,7 @@ def get_ip_addresses():
from lollms.server.endpoints.lollms_motion_ctrl import router as lollms_motion_ctrl

from endpoints.lollms_webui_infos import router as lollms_webui_infos_router
from endpoints.lollms_discussion import router as lollms_discussion_router
from lollms.server.endpoints.lollms_discussion import router as lollms_discussion_router
from endpoints.lollms_message import router as lollms_message_router
from endpoints.lollms_advanced import router as lollms_advanced_router
from endpoints.chat_bar import router as chat_bar_router
Expand Down
2 changes: 1 addition & 1 deletion endpoints/chat_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from lollms.main_config import BaseConfig
from lollms.utilities import detect_antiprompt, remove_text_from_string, trace_exception
from ascii_colors import ASCIIColors
from api.db import DiscussionsDB
from lollms.databases.discussions_database import DiscussionsDB
from pathlib import Path
from safe_store.text_vectorizer import TextVectorizer, VectorizationMethod, VisualizationMethod
import tqdm
Expand Down
2 changes: 1 addition & 1 deletion endpoints/lollms_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from lollms.utilities import detect_antiprompt, remove_text_from_string, trace_exception, show_yes_no_dialog
from lollms.security import sanitize_path
from ascii_colors import ASCIIColors
from api.db import DiscussionsDB
from lollms.databases.discussions_database import DiscussionsDB
from pathlib import Path
from safe_store.text_vectorizer import TextVectorizer, VectorizationMethod, VisualizationMethod
import tqdm
Expand Down
229 changes: 0 additions & 229 deletions endpoints/lollms_discussion.py

This file was deleted.

12 changes: 6 additions & 6 deletions endpoints/lollms_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from lollms.types import MSG_TYPE
from lollms.utilities import detect_antiprompt, remove_text_from_string, trace_exception
from ascii_colors import ASCIIColors
from api.db import DiscussionsDB
from lollms.databases.discussions_database import DiscussionsDB

from safe_store.text_vectorizer import TextVectorizer, VectorizationMethod, VisualizationMethod
import tqdm
Expand All @@ -41,7 +41,7 @@ async def edit_message(edit_params: EditMessageParameters):
new_message = edit_params.message
metadata = json.dumps(edit_params.metadata,indent=4)
try:
lollmsElfServer.connections[client_id]["current_discussion"].edit_message(message_id, new_message, new_metadata=metadata)
lollmsElfServer.session.get_client(client_id).discussion.edit_message(message_id, new_message, new_metadata=metadata)
return {"status": True}
except Exception as ex:
trace_exception(ex) # Assuming 'trace_exception' function logs the error
Expand All @@ -59,7 +59,7 @@ async def message_rank_up(rank_params: MessageRankParameters):
message_id = rank_params.id

try:
new_rank = lollmsElfServer.connections[client_id]["current_discussion"].message_rank_up(message_id)
new_rank = lollmsElfServer.session.get_client(client_id).discussion.message_rank_up(message_id)
return {"status": True, "new_rank": new_rank}
except Exception as ex:
trace_exception(ex) # Assuming 'trace_exception' function logs the error
Expand All @@ -71,7 +71,7 @@ def message_rank_down(rank_params: MessageRankParameters):
client_id = rank_params.client_id
message_id = rank_params.id
try:
new_rank = lollmsElfServer.connections[client_id]["current_discussion"].message_rank_down(message_id)
new_rank = lollmsElfServer.session.get_client(client_id).discussion.message_rank_down(message_id)
return {"status": True, "new_rank": new_rank}
except Exception as ex:
return {"status": False, "error":str(ex)}
Expand All @@ -85,11 +85,11 @@ async def delete_message(delete_params: MessageDeleteParameters):
client_id = delete_params.client_id
message_id = delete_params.id

if lollmsElfServer.connections[client_id]["current_discussion"] is None:
if lollmsElfServer.session.get_client(client_id).discussion is None:
return {"status": False,"message":"No discussion is selected"}
else:
try:
new_rank = lollmsElfServer.connections[client_id]["current_discussion"].delete_message(message_id)
new_rank = lollmsElfServer.session.get_client(client_id).discussion.delete_message(message_id)
ASCIIColors.yellow("Message deleted")
return {"status":True,"new_rank": new_rank}
except Exception as ex:
Expand Down
6 changes: 3 additions & 3 deletions events/lollms_chatbox_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import os
import time

from api.db import Discussion
from lollms.databases.discussions_database import Discussion
from datetime import datetime

router = APIRouter()
Expand All @@ -46,7 +46,7 @@ def create_empty_message(sid, data):
ASCIIColors.info(f"Building empty User message requested by : {client_id}")
# send the message to the bot
print(f"Creating an empty message for AI answer orientation")
if lollmsElfServer.connections[client_id]["current_discussion"]:
if lollmsElfServer.session.get_client(client_id).discussion:
if not lollmsElfServer.model:
lollmsElfServer.error("No model selected. Please make sure you select a model before starting generation", client_id = client_id)
return
Expand All @@ -58,7 +58,7 @@ def create_empty_message(sid, data):
ASCIIColors.info(f"Building empty AI message requested by : {client_id}")
# send the message to the bot
print(f"Creating an empty message for AI answer orientation")
if lollmsElfServer.connections[client_id]["current_discussion"]:
if lollmsElfServer.session.get_client(client_id).discussion:
if not lollmsElfServer.model:
lollmsElfServer.error("No model selected. Please make sure you select a model before starting generation", client_id=client_id)
return
Expand Down
Loading

0 comments on commit 02e829b

Please sign in to comment.