Do not historise the boreness question.
This commit is contained in:
@@ -87,11 +87,12 @@ class AIMessageBase(object):
|
||||
|
||||
|
||||
class AIMessage(AIMessageBase):
|
||||
def __init__(self, user: str, message: str, channel: str = "chat", direct: bool = False) -> None:
|
||||
def __init__(self, user: str, message: str, channel: str = "chat", direct: bool = False, historise_question: bool = True) -> None:
|
||||
self.user = user
|
||||
self.message = message
|
||||
self.channel = channel
|
||||
self.direct = direct
|
||||
self.historise_question = historise_question
|
||||
|
||||
|
||||
class AIResponse(AIMessageBase):
|
||||
@@ -322,8 +323,13 @@ class AIResponder(object):
|
||||
else:
|
||||
self.shrink_history_by_one(index + 1)
|
||||
|
||||
def update_history(self, question: Dict[str, Any], answer: Dict[str, Any], limit: int) -> None:
|
||||
self.history.append(question)
|
||||
def update_history(self,
|
||||
question: Dict[str, Any],
|
||||
answer: Dict[str, Any],
|
||||
limit: int,
|
||||
historise_question: bool = True) -> None:
|
||||
if historise_question:
|
||||
self.history.append(question)
|
||||
self.history.append(answer)
|
||||
while len(self.history) > limit:
|
||||
self.shrink_history_by_one()
|
||||
@@ -382,7 +388,7 @@ class AIResponder(object):
|
||||
answer['content'] = str(answer_message)
|
||||
|
||||
# Update message history
|
||||
self.update_history(messages[-1], answer, limit)
|
||||
self.update_history(messages[-1], answer, limit, message.historise_question)
|
||||
logging.info(f"got this answer:\n{str(answer_message)}")
|
||||
|
||||
# Return the updated answer message
|
||||
|
||||
Reference in New Issue
Block a user