mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
upgraded core
This commit is contained in:
parent
581a2157c4
commit
df4052e096
@ -576,7 +576,7 @@ class LollmsApplication(LoLLMsCom):
|
||||
|
||||
|
||||
|
||||
def process_chunk(
|
||||
def process_data(
|
||||
self,
|
||||
chunk:str,
|
||||
message_type,
|
||||
@ -900,7 +900,7 @@ class LollmsApplication(LoLLMsCom):
|
||||
system_message_template = self.config.system_message_template
|
||||
|
||||
if self.personality.callback is None:
|
||||
self.personality.callback = partial(self.process_chunk, client_id=client_id)
|
||||
self.personality.callback = partial(self.process_data, client_id=client_id)
|
||||
# Get the list of messages
|
||||
client = self.session.get_client(client_id)
|
||||
discussion = client.discussion
|
||||
|
@ -3015,9 +3015,9 @@ class APScript(StateMachine):
|
||||
callback = self.callback
|
||||
|
||||
if callback:
|
||||
callback("", MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_JSON_INFOS, metadata = [{"title":title, "content":json.dumps(json_infos, indent=indent)}])
|
||||
callback([{"title":title, "content":json.dumps(json_infos, indent=indent)}], MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_JSON_INFOS)
|
||||
|
||||
def ui(self, html_ui:str, callback: Callable[[str, MSG_OPERATION_TYPE, dict, list], bool]=None):
|
||||
def ui(self, html_ui:str, callback: Callable[[str, MSG_OPERATION_TYPE, dict, list], bool]|None=None):
|
||||
"""This sends ui elements to front end
|
||||
|
||||
Args:
|
||||
@ -3488,6 +3488,7 @@ class APScript(StateMachine):
|
||||
- 'file_name' (str): The name of the file extracted from the preceding line, if available.
|
||||
- 'content' (str): The content of the code block.
|
||||
- 'type' (str): The type of the code block. If the code block starts with a language specifier (like 'python' or 'java'), this field will contain that specifier. Otherwise, it will be set to 'language-specific'.
|
||||
- 'is_complete' (bool): True if the block has a closing tag, False otherwise.
|
||||
|
||||
Note:
|
||||
The function assumes that the number of triple backticks in the text is even.
|
||||
@ -3518,7 +3519,8 @@ class APScript(StateMachine):
|
||||
'file_name': "",
|
||||
'section': "",
|
||||
'content': "",
|
||||
'type': ""
|
||||
'type': "",
|
||||
'is_complete': False
|
||||
}
|
||||
if is_start:
|
||||
# Check the preceding line for file name
|
||||
@ -3528,6 +3530,9 @@ class APScript(StateMachine):
|
||||
if last_line.startswith("<file_name>") and last_line.endswith("</file_name>"):
|
||||
file_name = last_line[len("<file_name>"):-len("</file_name>")].strip()
|
||||
block_infos['file_name'] = file_name
|
||||
elif last_line.startswith("## filename:"):
|
||||
file_name = last_line[len("## filename:"):].strip()
|
||||
block_infos['file_name'] = file_name
|
||||
if last_line.startswith("<section>") and last_line.endswith("</section>"):
|
||||
section = last_line[len("<section>"):-len("</section>")].strip()
|
||||
block_infos['section'] = section
|
||||
@ -3551,11 +3556,17 @@ class APScript(StateMachine):
|
||||
else:
|
||||
block_infos["type"] = sub_text[:next_index]
|
||||
|
||||
next_pos = indices[index + 1] - code_delimiter_position
|
||||
if next_pos - 3<len(sub_text) and sub_text[next_pos - 3] == "`":
|
||||
block_infos["content"] = sub_text[start_pos:next_pos - 3].strip()
|
||||
if index + 1 < len(indices):
|
||||
next_pos = indices[index + 1] - code_delimiter_position
|
||||
if next_pos - 3 < len(sub_text) and sub_text[next_pos - 3] == "`":
|
||||
block_infos["content"] = sub_text[start_pos:next_pos - 3].strip()
|
||||
block_infos["is_complete"] = True
|
||||
else:
|
||||
block_infos["content"] = sub_text[start_pos:next_pos].strip()
|
||||
block_infos["is_complete"] = False
|
||||
else:
|
||||
block_infos["content"] = sub_text[start_pos:next_pos].strip()
|
||||
block_infos["content"] = sub_text[start_pos:].strip()
|
||||
block_infos["is_complete"] = False
|
||||
code_blocks.append(block_infos)
|
||||
is_start = False
|
||||
else:
|
||||
@ -3564,9 +3575,6 @@ class APScript(StateMachine):
|
||||
|
||||
return code_blocks
|
||||
|
||||
|
||||
|
||||
|
||||
def build_and_execute_python_code(self,context, instructions, execution_function_signature, extra_imports=""):
|
||||
start_header_id_template = self.config.start_header_id_template
|
||||
end_header_id_template = self.config.end_header_id_template
|
||||
|
@ -106,6 +106,7 @@ async def edit_title(discussion_edit_title: DiscussionEditTitle):
|
||||
return {"status":False,"error":str(ex)}
|
||||
|
||||
class DiscussionTitle(BaseModel):
|
||||
client_id: str
|
||||
id: int
|
||||
|
||||
@router.post("/make_title")
|
||||
@ -114,7 +115,7 @@ async def make_title(discussion_title: DiscussionTitle):
|
||||
ASCIIColors.info("Making title")
|
||||
discussion_id = discussion_title.id
|
||||
discussion = Discussion(lollmsElfServer, discussion_id, lollmsElfServer.db)
|
||||
title = lollmsElfServer.make_discussion_title(discussion)
|
||||
title = lollmsElfServer.make_discussion_title(discussion, discussion_title.client_id)
|
||||
discussion.rename(title)
|
||||
return {'status':True, 'title':title}
|
||||
except Exception as ex:
|
||||
|
@ -128,6 +128,8 @@ async def add_document(doc: IndexDocument, user: str = Depends(get_current_user)
|
||||
async def remove_document(document_id: int, user: str = Depends(get_current_user)):
|
||||
user_id = get_user_id(user)
|
||||
vectorizer = get_user_vectorizer(user_id, user)
|
||||
doc_hash = vectorizer.get_document_hash(document_id)
|
||||
vectorizer.remove_document(doc_hash)
|
||||
# Logic to remove the document by ID
|
||||
return DocumentResponse(success=True, message="Document removed successfully.")
|
||||
|
||||
|
@ -36,13 +36,13 @@ def add_events(sio:socketio):
|
||||
try:
|
||||
if not lollmsElfServer.personality.processor is None:
|
||||
file.save(save_path)
|
||||
lollmsElfServer.personality.processor.add_file(save_path, partial(lollmsElfServer.process_chunk, client_id = sid))
|
||||
lollmsElfServer.personality.processor.add_file(save_path, partial(lollmsElfServer.process_data, client_id = sid))
|
||||
# File saved successfully
|
||||
run_async(partial(sio.emit,'progress', {'status':True, 'progress': 100}))
|
||||
|
||||
else:
|
||||
file.save(save_path)
|
||||
lollmsElfServer.personality.add_file(save_path, partial(lollmsElfServer.process_chunk, client_id = sid))
|
||||
lollmsElfServer.personality.add_file(save_path, partial(lollmsElfServer.process_data, client_id = sid))
|
||||
# File saved successfully
|
||||
run_async(partial(sio.emit,'progress', {'status':True, 'progress': 100}))
|
||||
except Exception as e:
|
||||
|
@ -42,7 +42,7 @@ def add_events(sio:socketio):
|
||||
client.cancel_generation = False
|
||||
|
||||
try:
|
||||
lollmsElfServer.personality.setCallback(partial(lollmsElfServer.process_chunk,client_id = client_id))
|
||||
lollmsElfServer.personality.setCallback(partial(lollmsElfServer.process_data,client_id = client_id))
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
|
||||
@ -109,9 +109,9 @@ def add_events(sio:socketio):
|
||||
lollmsElfServer.ShowBlockingMessage(f"File received {file_path.name}.\nVectorizing the data ...")
|
||||
|
||||
if lollmsElfServer.personality.processor:
|
||||
result = client.discussion.add_file(file_path, client, lollmsElfServer.tasks_library, partial(lollmsElfServer.process_chunk, client_id=client_id))
|
||||
result = client.discussion.add_file(file_path, client, lollmsElfServer.tasks_library, partial(lollmsElfServer.process_data, client_id=client_id))
|
||||
else:
|
||||
result = client.discussion.add_file(file_path, client, lollmsElfServer.tasks_library, partial(lollmsElfServer.process_chunk, client_id=client_id))
|
||||
result = client.discussion.add_file(file_path, client, lollmsElfServer.tasks_library, partial(lollmsElfServer.process_data, client_id=client_id))
|
||||
|
||||
ASCIIColors.success('File processed successfully')
|
||||
run_async(partial(sio.emit,'file_received', {'status': True, 'filename': filename}))
|
||||
@ -162,7 +162,7 @@ def add_events(sio:socketio):
|
||||
lollmsElfServer.prepare_reception(client_id)
|
||||
if lollmsElfServer.personality.processor is not None:
|
||||
lollmsElfServer.start_time = datetime.now()
|
||||
lollmsElfServer.personality.processor.callback = partial(lollmsElfServer.process_chunk, client_id=client_id)
|
||||
lollmsElfServer.personality.processor.callback = partial(lollmsElfServer.process_data, client_id=client_id)
|
||||
lollmsElfServer.personality.vectorizer = client.discussion.vectorizer
|
||||
lollmsElfServer.personality.text_files = client.discussion.text_files
|
||||
lollmsElfServer.personality.image_files = client.discussion.image_files
|
||||
|
Loading…
Reference in New Issue
Block a user