FastChat icon indicating copy to clipboard operation
FastChat copied to clipboard

Issue#89 move content moderation warning messages to the chatbot box

Open yantao0527 opened this issue 2 years ago • 3 comments
trafficstars

Identify the records in chatbox and the records in prompt by adding flag is_prompt in messages. The default value of is_prompt is True. Set the flag of the last pair of messages to False when the below situations happen:

  • Violate moderation of content
  • No available worker
  • Regenerate
  • Network error or exception

In addition, there are too many condition statements here, it is recommended to use object encapsulation to refactor the code.

yantao0527 avatar Apr 25 '23 02:04 yantao0527

@yantao0527 Thanks for the contribution! We did some refactoring. Could you rebase to the latest main branch?

Regards the changes, I feel like adding a new field is_prompt complicates the design of the Conversation class. We may not want to add this field. Are there any other options?

merrymercy avatar Apr 29 '23 13:04 merrymercy

@merrymercy I understand adding a new field into Conversation class that is already complicated is a bad idea. Let me think about how to reduce the complexity of Conversation class. I'm going to commit the example code to continue to discuss it.

yantao0527 avatar Apr 30 '23 16:04 yantao0527

In order to reduce the complexity, I split Conversion class into two parts, Prompt class and Session class, in fastchat/session.py.

yantao0527 avatar May 01 '23 13:05 yantao0527

Thanks for the new design. It looks better but I guess I still need more time to think about this important design and change. I will review it later.

merrymercy avatar May 05 '23 10:05 merrymercy

Message class represents the life cycle of a interactive that occurs from user input to system output, also includes moderation, http request bot, vote result, or other performance data. So need to continue to refactor the code.

yantao0527 avatar May 05 '23 13:05 yantao0527

Yes. It is very complicated and I may have my own design. I will also think about how to make it easier to support new models (both open-source and close-source). Because of its importance, I may refactor by myself and reference your design. The chance of accepting this kind of big refactor from external contributors is low. You can wait for my refactor.

merrymercy avatar May 05 '23 14:05 merrymercy

Sure. I just provided my thought to reference after I learned project code. I'm glad to discuss it with you and look forward your refactor.

yantao0527 avatar May 05 '23 15:05 yantao0527