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

I have some questions #8

Open
NigaKniga opened this issue May 17, 2023 · 2 comments
Open

I have some questions #8

NigaKniga opened this issue May 17, 2023 · 2 comments

Comments

@NigaKniga
Copy link

NigaKniga commented May 17, 2023

I would like to ask a couple questions since there is almost nothing I can find online on how Claude works with Tavern. An input from a knowledgeable person would be greatly appreciated.

  1. What will happen if I edit {{char}} or {{user}} messages inside Tavern? Would claude somehow receive and edited version and continue replying keeping that in memory or is it a purely cosmetical, local, front end option? What will happen if I delete a reply? I don't think it will be deleted inside Slack chat. Will it be marked as irrelevant and removed from Claude memory, saving tokens? Or is it again, a front end only feature?

  2. How does token limit work? My exchange with Claude is a continuous stream of messages inside the Slack chat. Does all of them contribute to token limit or does it only apply to a single chat with a given character? Like if I start a new chat token limit will be re-set again?

  3. If I start a new chat with char №1, pause it, start a chat with char №2, then return to chat with char №1, how will it even work? It would look like that in slack:

Char №1 session
Char №2 session
Char №1 session

It looks like a total mess. Would Claude "understand" that I want to continue my previous session with char №1, discard tokens of char №2 chat, load tokens of char №1 chat back in its memory to continue the exchange?
Would such a buildup of messages in slack mess with the output? I noticed that after Claude refuses to continue describing an NSFW scene, output a bunch of "I can't continue this roleplay" warnings, then I start a new chat with a different character, start typing something SFW and Claude just enters an "I can't continue this roleplay" stupor, outputting this warning even in a SFW context.

  1. Does sliding or re-generating a reply wastes tokens? Only one reply will serve as a point of exchange continuation, what happens with other generated variants? Will they get removed from the memory, saving up tokens since they are irrelevant or will they stay in the memory and contribute to token limit regardless?
@PandarusAnon
Copy link
Owner

Most of your questions come down to a fundamental misunderstanding how all of this works.

The workflow of generating a response is as following:

  1. You type a message in SillyTavern and hit enter/click Send
  2. SillyTavern takes the prompts from the preset, the character definition and as much of everything else (like chat history) as it can fit without exceeding the token limit configured in SillyTavern and sends it as an OpenAI prompt
  3. Slaude, posing as an OpenAI proxy, receives the message
  4. The individual of the prompt get converted into multiple plain text messages we will send to Slack as the context
  5. A thread is created in the configured Slack channel with the first message
  6. All remaining messages will be created as replies to that thread
  7. The final message pings Claude in Slack, causing him to generate a response
  8. Slaude waits for that response and sends it back to SillyTavern, pretending to be an OpenAI chat completion response
  9. You can now freely edit any part of the response, the chat history or swipe to regenerate
  10. Repeat from step 1 with the (potentially edited) history

The important thing to understand here is that Claude has no memory outside of each thread. Every time we create a thread and ping Claude it's the first time we have ever done so from Claude's perspective. Claude has no memory if this is the first thread or the thousandth thread and knows nothing about what happened in these threads. The only way Claude would retain anything about your previous prompt is if you went back into one of the Slack threads yourself on the Slack client and manually asked Claude additional questions about the stuff that happened in that thread.

So every time we want a new response from Claude we create a thread and then essentially tell him "OK, so this is what we're going to be doing, this is the character you will be roleplaying as, these are some examples for how the character would interact with the user and last is an ongoing conversation between the user and this character, with the last message being from the user. The user is Human in this history and the character is Assistant. Taking all of this information into account, continue this conversation as the character".

Since Claude starts at zero every time we create a thread the only thing he "remembers" about the previous conversation is what we send him as part of the prompt.

To maybe humanize Claude a bit, imagine Claude is an amnesiac. Every time Claude responds to us, he forgets absolutely everything that just happened. So to continue the conversation we need to remind him every time who he is and what we have talked about so far so he can use this information to formulate his next response before forgetting everything again. Since Claude loses his memory after responding he has no choice but to believe that the chat history we send him is the truth.

So let's say Claude just responded with "I like ketchup". In SillyTavern you edit the response to say "I like mayonnaise" and then write "Nice, I like mayonnaise too!". Now in his response Claude will not go "But I said I like ketchup" because he has no memory of just having said that. Instead he sees your prompt, thinks "ah, yes, of course, I just said that I like mayonnaise, thanks for reminding me" and then responds with something like "Well, I'm glad we like the same things!".

And to answer at least your first question directly, SillyTavern replaces {{user}} with the name you set in SillyTavern and {{char}} with the character name before sending the prompt. Claude then gets them with the replacement and that's all there is to it. If you decide halfway into the conversation that you would rather the character be called something else, then SillyTavern will replace {{char}} with the new name for the next prompt and since Claude has no internal memory of the conversation he will assume that the character name has just always been the new one.

@NigaKniga
Copy link
Author

Thanks so much for taking some time to reply to me. LLMs are new to me, so yes, I don't know a lot of the basics. This information you provided is extremely helpful. I am sure other people with lack of knowledge, who decided to use Tavern AI and Slaude will find this read useful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants