brucepro / Memoir

Memoir+ a persona extension for Text Gen Web UI. That includes memory, emotions, command handling and more.
MIT License
174 stars 21 forks source link

script.py TypeError: can only concatenate str (not "list") to str #24

Open mar-tok opened 8 months ago

mar-tok commented 8 months ago

Occurs when using the /v1/chat/completions endpoint. Can't concatenate a list to a string using the + operator in Python, so this will halt any the generation requested. The issue is specifically the state['custom_stopping_strings. It does work fine in the webui itself, though.

File "C:\LLM\text-generation-webui-main\extensions\Memoir\script.py", line 89, in state_modifier state['custom_stopping_strings'] = '"[DateTime=","[24hour Average Polarity Score=","' + str(state["name1"].strip()) + ':",' + state['custom_stopping_strings'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TypeError: can only concatenate str (not "list") to str

brucepro commented 8 months ago

I need to add in checks for api.

wepromen commented 5 months ago

Me too, any idea? This is my code:

import requests

url = "http://127.0.0.1:5000/v1/chat/completions"

headers = {
    "Content-Type": "application/json"
}

history = []

while True:
    user_message = input("> ")
    history.append({"role": "user", "content": user_message})
    data = {
        "mode": "chat",
        "character": "IUX",
        "user": "user1",
        "name2": "IUX",
        "messages": history
    }

response = requests.post(url, headers=headers, json=data, verify=False)
assistant_message = response.json()['choices'][0]['message']['content']
history.append({"role": "assistant", "content": assistant_message})
print(assistant_message)
brucepro commented 5 months ago

I think the api side handles the stopping strings a bit differently. Comment out the line. I will do some testing.