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

Fix: Refresh delay and improve performance by using patch strategy to update messages and interactions #84

Merged
merged 12 commits into from
Dec 27, 2023

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Dec 22, 2023

Description

[Describe what this change achieves]

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
@SuZhou-Joe SuZhou-Joe marked this pull request as ready for review December 25, 2023 02:48
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a474220) 89.15% compared to head (01a30d1) 93.26%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   89.15%   93.26%   +4.10%     
==========================================
  Files          43       46       +3     
  Lines        1033     1218     +185     
  Branches      241      291      +50     
==========================================
+ Hits          921     1136     +215     
+ Misses        111       80      -31     
- Partials        1        2       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

public/hooks/use_chat_actions.tsx Outdated Show resolved Hide resolved
server/routes/chat_routes.ts Show resolved Hide resolved
server/routes/regenerate.test.ts Outdated Show resolved Hide resolved
server/utils/message_parser_runner.ts Show resolved Hide resolved
server/routes/send_message.test.ts Outdated Show resolved Hide resolved
* As in Olly, regenerate and send_message API will only response with the latest one interaction and messages to improve performance.
* So we need to use patch to hanlde with the response.
*/
case 'patch':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the patch action always follow receive action. Shall we just merge patch action to receive action?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the patch action always follow receive action

For now, yes because for send_message and regenerate action, we append dummy input message and when we do patch, we need to call receive to remove the dummy message. But there are cases that we only call receive action without patch action.

Shall we just merge patch action to receive action

I'd say no because patch action can only do add/update, not able to "remove" a useless message/interaction. Only receive action can do that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I missed the case in loadChat. The loadChat will call receive action without patch.
My original thoughts was to refactor the receive action to accept patch messages and interactions like below code:

    dispatch({
        type: 'receive',
        payload: {
          messages: response.messages,
          interactions: response.interactions,
          patch: {messages, interactions}
        },
      });

We can add an optional patch parameter, and complete patch inside receive action.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking if that's too much for a single action to do set as well as patch.

Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
@SuZhou-Joe SuZhou-Joe merged commit e125773 into opensearch-project:main Dec 27, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants