Skip to content

Option to lock messages so responseInterceptor modifies the last AI message, not the first available #463

@nicholasturk

Description

@nicholasturk

When a response is streaming, in the response interceptor you can add messages

const responseInterceptor = (response) => {
  if (message.text === "special") {
     return deepChat.addMessage(formatSpecialMessage(response))
  }
  if (domContainsSpecial()) {
     removeSpecial()
     deepChat.addMessage(response)
  }
  return response;
};

So a streamed response like this:

["Foo", "special", "Bar", "Baz"]

Would generate a DeepChat output like:
1.
Foo
2.
Foo
Special
3.
Foo
Bar
4.
Foo Baz
Bar

However, I want the final output to be

Foo
Bar Baz

So the last streamed messages gets appended to the last message. Is this possible?

Metadata

Metadata

Labels

adviceInformation how to use/implement the component

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions