Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMP: method ad hoc for max user input #588

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions core/cat/looking_glass/cheshire_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,7 @@ def __call__(self, user_message_json):

# split text after MAX_TEXT_INPUT tokens, on a whitespace, if any, and send it to declarative memory
if len(user_message_json["text"]) > MAX_TEXT_INPUT:
index = MAX_TEXT_INPUT
char = user_message_json["text"][index]
while not char.isspace() and index > 0:
index -= 1
char = user_message_json["text"][index]
if index <= 0:
index = MAX_TEXT_INPUT
user_message_json["text"], to_declarative_memory = user_message_json["text"][:index], user_message_json["text"][index:]
docs = self.rabbit_hole.string_to_docs(to_declarative_memory, content_type="text/plain")
self.rabbit_hole.store_documents(docs=docs, source="")
self.store_long_input_to_declarative(user_message_json)

# store last message in working memory
user_working_memory["user_message_json"] = user_message_json
Expand Down Expand Up @@ -553,3 +544,15 @@ def get_static_path():
"""Allows the Cat exposing the static files path."""
log.warning("This method will be removed, import cat.utils tu usit instead.")
return utils.get_static_path()

def store_long_input_to_declarative(self, user_message_json):
index = MAX_TEXT_INPUT
char = user_message_json["text"][index]
while not char.isspace() and index > 0:
index -= 1
char = user_message_json["text"][index]
if index <= 0:
index = MAX_TEXT_INPUT
user_message_json["text"], to_declarative_memory = user_message_json["text"][:index], user_message_json["text"][index:]
docs = self.rabbit_hole.string_to_docs(to_declarative_memory, content_type="text/plain")
self.rabbit_hole.store_documents(docs=docs, source="")
Loading