From be6718849ff072f343b7e486d373e872a57843ca Mon Sep 17 00:00:00 2001 From: Aries-ckt <916701291@qq.com> Date: Wed, 24 Jan 2024 23:03:08 +0800 Subject: [PATCH] fix:default setting prompt with history messages (#1117) Co-authored-by: Fangyin Cheng --- .../interface/operators/message_operator.py | 19 ++++++++++++++++++- dbgpt/storage/vector_store/milvus_store.py | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dbgpt/core/interface/operators/message_operator.py b/dbgpt/core/interface/operators/message_operator.py index 3a3ae2dea..e5d514c84 100644 --- a/dbgpt/core/interface/operators/message_operator.py +++ b/dbgpt/core/interface/operators/message_operator.py @@ -416,6 +416,18 @@ class BufferedConversationMapperOperator(ConversationMapperOperator): ... ], ... ] + # Test end rounds is zero + >>> operator = BufferedConversationMapperOperator( + ... keep_start_rounds=1, keep_end_rounds=0 + ... ) + >>> assert operator._filter_round_messages(messages) == [ + ... [ + ... HumanMessage(content="Hi", round_index=1), + ... AIMessage(content="Hello!", round_index=1), + ... ] + ... ] + + Args: messages_by_round (List[List[BaseMessage]]): The messages grouped by round. @@ -425,7 +437,12 @@ class BufferedConversationMapperOperator(ConversationMapperOperator): """ total_rounds = len(messages_by_round) - if self._keep_start_rounds is not None and self._keep_end_rounds is not None: + if ( + self._keep_start_rounds is not None + and self._keep_end_rounds is not None + and self._keep_start_rounds > 0 + and self._keep_end_rounds > 0 + ): if self._keep_start_rounds + self._keep_end_rounds > total_rounds: # Avoid overlapping when the sum of start and end rounds exceeds total # rounds diff --git a/dbgpt/storage/vector_store/milvus_store.py b/dbgpt/storage/vector_store/milvus_store.py index 4f97cdd50..2daedf08a 100644 --- a/dbgpt/storage/vector_store/milvus_store.py +++ b/dbgpt/storage/vector_store/milvus_store.py @@ -133,8 +133,9 @@ class MilvusStore(VectorStoreBase): connections.connect( host=self.uri or "127.0.0.1", port=self.port or "19530", - alias="default" - # secure=self.secure, + username=self.username, + password=self.password, + alias="default", ) def init_schema_and_load(self, vector_name, documents) -> List[str]: