GithubHelp home page GithubHelp logo

theubie / complex_memory Goto Github PK

View Code? Open in Web Editor NEW
106.0 106.0 14.0 219 KB

A KoboldAI-like memory extension for oobabooga's text-generation-webui

License: GNU Affero General Public License v3.0

Python 100.00%

complex_memory's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @theubie
  • ๐Ÿ‘€ Iโ€™m the owner and lead developer for Creative Technology Services
  • ๐Ÿ“ซ You can reach me via email in my profile, or at our company's site: https://nvcreativetechnology.com

complex_memory's People

Contributors

dibrale avatar remghoost avatar theubie avatar tsngo avatar weavertron5000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

complex_memory's Issues

I get an error about no attribute 'character'

"Traceback (most recent call last):
File "G:-AI\oobabooga_windows\text-generation-webui\server.py", line 1186, in
create_interface()
File "G:-AI\oobabooga_windows\text-generation-webui\server.py", line 1079, in create_interface
extensions_module.create_extensions_block()
File "G:-AI\oobabooga_windows\text-generation-webui\modules\extensions.py", line 175, in create_extensions_block
extension.ui()
File "G:-AI\oobabooga_windows\text-generation-webui\extensions\complex_memory\script.py", line 182, in ui
load_pairs()
File "G:-AI\oobabooga_windows\text-generation-webui\extensions\complex_memory\script.py", line 84, in load_pairs
if shared.character is not None and shared.character != "None":
AttributeError: module 'modules.shared' has no attribute 'character'"

Does it work with the oobabot extension?

With it enabled complex_memory works fine in the webui
But seemingly doesn't at all over Discord with oobabot
I tried to make sure it was using the same character, that didn't seem to make a difference

KeyError: 'dummy' on extension load

Loading of complex_memory extension throws the error:

--Unable to load complex memories for character Assistant. filename: characters/Assistant.json. Using defaults.
Traceback (most recent call last):
File "text-generation-webui/server.py", line 247, in
create_interface()
File "text-generation-webui/server.py", line 153, in create_interface
extensions_module.create_extensions_block() # Extensions block
File "text-generation-webui/modules/extensions.py", line 192, in create_extensions_block
extension.ui()
File "text-generation-webui/extensions/complex_memory/script.py", line 257, in ui
[shared.gradio[k] for k in ['name1', 'name2', 'character_picture', 'greeting', 'context', 'dummy']]).then(
File "text-generation-webui/extensions/complex_memory/script.py", line 257, in
[shared.gradio[k] for k in ['name1', 'name2', 'character_picture', 'greeting', 'context', 'dummy']]).then(
KeyError: 'dummy'

I was able to clear the error by updating the code
from:
[shared.gradio[k] for k in ['character_menu', 'name1', 'name2']],
[shared.gradio[k] for k in ['name1', 'name2', 'character_picture', 'greeting', 'context', 'dummy']]).then(
chat.redraw_html, shared.reload_inputs, shared.gradio['display']).then(pairs_loaded, None, memory_select)
to:
[shared.gradio[k] for k in ['character_menu', 'name1', 'name2'] if k in shared.gradio],
[shared.gradio[k] for k in ['name1', 'name2', 'character_picture', 'greeting', 'context', 'dummy'] if k in shared.gradio]).then(
chat.redraw_html, shared.reload_inputs, shared.gradio['display']).then(pairs_loaded, None, memory_select)

but then, on character file upload to text-generation-webui, it will throw the error:

File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 407, in call_prediction
output = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 226, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1550, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1185, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 661, in wrapper
response = f(*args, **kwargs)
File "text-generation-webui/extensions/complex_memory/script.py", line 157, in load_character_complex_memory_hijack
result = chat.load_character(character_menu, name1, name2, False)
TypeError: load_character() takes 3 positional arguments but 4 were given

enable complex_memory in text generation mode?

Hi,
This plugin is eactly what I have been looking for to generate stories. But unfortunately it does not seem to kick in when I use it in text generation mode?
I set Verbose to TRUE, but do not see any of my memories getting added to the text generation in the cmd prompt.
Does it only work with Chat window, or am I doing something wrong?

Oobabooga style update breaks complex_memory

Oobabooga released a commit that added styles to the chats, and complex memory now causes characters to load improperly. The chat.load_character function now includes a style variable and this is breaking the extension with error

Traceback (most recent call last):
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\gradio\routes.py", line 395, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\gradio\blocks.py", line 1193, in process_api
result = await self.call_function(
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\gradio\blocks.py", line 916, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "C:\Users\user\Desktop\oobabooga_windows\installer_files\env\lib\site-packages\anyio_backends_asyncio.py", line 867, in run
result = context.run(func, *args)
File "C:\Users\user\Desktop\oobabooga_windows\text-generation-webui\extensions\complex_memory\script.py", line 155, in load_character_complex_memory_hijack
result = chat.load_character(character_menu, name1, name2, mode)
TypeError: load_character() missing 1 required positional argument: 'style'

I've tried just adding the style argument to line 155, and subsequently 153, 256, and 257 leading to errors that aren't likely helpful.

Traceback Error

The extensions worked fine, but when I update the webui. It gives me an error:
Capture

Cache error: file is locked by another process

This extension creates pfp_character.png in the cache, but crashes the next time it attempts to access it because "PermissionError: [WinError 32] The process cannot access the file because it is being used by another process".

Error occurs in line 157 of script.py:

result = chat.load_character(character_menu, name1, name2, False)

suggestion

Can the code be expanded so it could encapsulate a syntax for scripting engine , for exampe if id feed it this , so it could look up the syntax and produce better code ?
https://gist.github.com/2blackbar/824467c8b604a81bab92e9c56fe78ad6

Also can you make it overwrite default knowledge within the model? when i for example create own memory with known name then its not using the memmory that i created . so i have to come up with unique not known name for memory.

also i noticed that it starts to mixup memories from different keywords if the names are similar, for example have two crew names and in the crew1 theres a person named amerika, in crew2 theres person named abigail, and the chat sometimes mixes up their names and abilities...

I cant get it to work

Hi, I tried both, the direct copy in from the zip file and also the installation via pip. The files look identical with the git, but every time i want to load it (flag or via extension checkbox) I get this:

C:\Projects\Text\oobabooga-windows\installer_files\env\lib\site-packages\gradio\deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.
warnings.warn(value)
--Unable to load complex memories for character AlpacaRadio. filename: characters/AlpacaRadio.json. Using defaults.
Traceback (most recent call last):
File "C:\Projects\Text\oobabooga-windows\text-generation-webui\server.py", line 572, in
create_interface()
File "C:\Projects\Text\oobabooga-windows\text-generation-webui\server.py", line 532, in create_interface
extensions_module.create_extensions_block()
File "C:\Projects\Text\oobabooga-windows\text-generation-webui\modules\extensions.py", line 69, in create_extensions_block
extension.ui()
File "C:\Projects\Text\oobabooga-windows\text-generation-webui\extensions\complex_memory\script.py", line 308, in ui
[shared.gradio[k] for k in ['character_menu', 'name1', 'name2', 'mode']],
File "C:\Projects\Text\oobabooga-windows\text-generation-webui\extensions\complex_memory\script.py", line 308, in
[shared.gradio[k] for k in ['character_menu', 'name1', 'name2', 'mode']],
KeyError: 'mode'

Improved keyword search

Hi, I like your plugin very much. I think I made an useful improvement I would like to share with you:

Currently if you have a memory keyword like "AI", it will trigger the memory even if the user is typing "ain't it?". Alone it's not that big of a problem, but when you're having dozens of memory slots like me, many of them with short keywords, it starts to become one. So, I took the liberty to alter your keyword detection code.

in the imports you'll need to add
import re

then, replace everything between # create out memory rows and if memory_settings["position"] == "Before Context":

    context_injection = []
    context_found = False
    for pair in pairs:
        if pair["always"]:
            # Always inject it.
            context_injection.append(pair["memory"])
            context_found = True
        else:
            # Check to see if keywords are present.
            keywords = pair["keywords"].lower().split(",")
            user_input_lower = user_input.lower()
            for keyword in keywords:
                if len(keyword.split()) > 1:
                    if keyword in user_input_lower:
                        context_injection.append(pair["memory"])
                        context_found = True
                        break  # exit the loop if a match is found
                else:
                    if re.search(r'\b{}\b'.format(keyword.strip()), user_input_lower):
                        # keyword is present in user_input
                        context_injection.append(pair["memory"])
                        context_found = True
                        break  # exit the loop if a match is found

    # Add the context_injection
    if context_found:
        context_injection_string = f"\n{state['name2']}'s important memories: " + (' '.join(context_injection)).strip()
    else:
        context_injection_string = ''

My python skills are terrible, you can likely concatenate those strings better, but that's the gist of it. What it does:

  1. If the keyword is composed of 2 or more words, it'll use your method and just look into the user_input to see if it's there.
  2. If the keyword is a singular word, it'll use a regex expression to separate the user_input into individual words so keywords like AI will only load a memory if "AI" was actually typed.
  3. It automatically takes care of the punctuation "AI!" and "AI?" will still be detected properly.

Additionally, I've noticed that using this format: bot's important memories: $list was working extremely well.

My apologies for not doing a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.