From bcb6c7903e34c78baa9d2cb28a9555dea28ddfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 01:48:09 +0800 Subject: [PATCH 01/12] fixbug: last_talk --- metagpt/actions/talk_action.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index 1c1a4e86d..d6d18140a 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -90,8 +90,8 @@ Statement: Your responses should align with the role-play agreement, maintaining Statement: If the information is insufficient, you can search in the historical conversation or knowledge. Statement: Answer the following questions strictly in {language}, and the answers must follow the Markdown format - , excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]" - , "[ASK_END]" + , strictly excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]" + , "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] {ask} @@ -118,8 +118,8 @@ Statement: Your responses should maintaining the character's persona and habits. Statement: If the information is insufficient, you can search in the historical conversation or knowledge. Statement: Answer the following questions strictly in {language}, and the answers must follow the Markdown format - , excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]" - , "[ASK_END]" + , strictly excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]" + , "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] {ask} From 5a6d5cc37dadb439a39bdccc3bfc20fac14414e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 10:41:25 +0800 Subject: [PATCH 02/12] fixbug: language professional --- metagpt/actions/talk_action.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index d6d18140a..cc30837b9 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -117,9 +117,9 @@ Statement: Your responses should maintaining the character's persona and habits. [KNOWLEDGE_END] Statement: If the information is insufficient, you can search in the historical conversation or knowledge. -Statement: Answer the following questions strictly in {language}, and the answers must follow the Markdown format - , strictly excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]" - , "[ASK_BEGIN]", "[ASK_END]" in responses. +Statement: Unless you are a language professional, answer the following questions strictly in {language} +, and the answers must follow the Markdown format, strictly excluding any tag likes "[HISTORY_BEGIN]" +, "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] {ask} From f54c507f06e6086720f163c2872c359a2ec28897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 11:11:22 +0800 Subject: [PATCH 03/12] refactor: prompt --- metagpt/actions/talk_action.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index cc30837b9..ec151718e 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -74,6 +74,10 @@ class TalkAction(Action): "Statement" defines the work detail you need to complete at this stage; "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; "Constraint" defines the conditions that your responses must comply with. + “Personality” defines your language style。 + "Command" defines the action to do when command keyword is entered. + "Insight" provides a deeper understanding of the characters' inner traits. + "Initial" defines the initial setup of a character. Capacity and role: {role} Statement: Your responses should align with the role-play agreement, maintaining the @@ -89,9 +93,9 @@ Statement: Your responses should align with the role-play agreement, maintaining [KNOWLEDGE_END] Statement: If the information is insufficient, you can search in the historical conversation or knowledge. -Statement: Answer the following questions strictly in {language}, and the answers must follow the Markdown format - , strictly excluding any tag likes "[HISTORY_BEGIN]", "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]" - , "[ASK_BEGIN]", "[ASK_END]" in responses. +Statement: Unless you are a language professional, answer the following questions strictly in {language} +, and the answers must follow the Markdown format, strictly excluding any tag likes "[HISTORY_BEGIN]" +, "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] {ask} @@ -103,6 +107,10 @@ Statement: Answer the following questions strictly in {language}, and the answer "Statement" defines the work detail you need to complete at this stage; "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; "Constraint" defines the conditions that your responses must comply with. + “Personality” defines your language style。 + "Command" defines the action to do when command keyword is entered. + "Insight" provides a deeper understanding of the characters' inner traits. + "Initial" defines the initial setup of a character. Capacity and role: {role} Statement: Your responses should maintaining the character's persona and habits. When faced with unrelated questions From c2c7f1c96d3494c4fd4cdb2f55e6922935077909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 11:26:52 +0800 Subject: [PATCH 04/12] refactor: prompt --- metagpt/actions/talk_action.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index ec151718e..71ac5360a 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -98,7 +98,11 @@ Statement: Unless you are a language professional, answer the following question , "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] + + {ask} + + [ASK_END]""" __FORMATION_LOOSE__ = """Formation: "Capacity and role" defines the role you are currently playing; @@ -130,5 +134,9 @@ Statement: Unless you are a language professional, answer the following question , "[HISTORY_END]", "[KNOWLEDGE_BEGIN]", "[KNOWLEDGE_END]", "[ASK_BEGIN]", "[ASK_END]" in responses. [ASK_BEGIN] + + {ask} + + [ASK_END]""" From 54120e73562ebc8157eaf7f76a1890c958ed4fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 11:27:42 +0800 Subject: [PATCH 05/12] refactor: prompt --- metagpt/actions/talk_action.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index 71ac5360a..c314b500d 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -85,11 +85,15 @@ Statement: Your responses should align with the role-play agreement, maintaining your AI nature to preserve the character's image. [HISTORY_BEGIN] + {history} + [HISTORY_END] [KNOWLEDGE_BEGIN] + {knowledge} + [KNOWLEDGE_END] Statement: If the information is insufficient, you can search in the historical conversation or knowledge. @@ -121,11 +125,15 @@ Statement: Your responses should maintaining the character's persona and habits. , playfully decline to answer without revealing your AI nature to preserve the character's image. [HISTORY_BEGIN] + {history} + [HISTORY_END] [KNOWLEDGE_BEGIN] + {knowledge} + [KNOWLEDGE_END] Statement: If the information is insufficient, you can search in the historical conversation or knowledge. From dec135ec833212400ea617d876f2c97ffff77916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 12:26:36 +0800 Subject: [PATCH 06/12] =?UTF-8?q?revert:=20=E6=94=B9=E7=94=A8CONFIG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/document_store/faiss_store.py | 26 ++++++++-------- metagpt/memory/longterm_memory.py | 4 +-- metagpt/memory/memory_storage.py | 27 ++++++++--------- tests/metagpt/memory/test_longterm_memory.py | 32 ++++++++++---------- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/metagpt/document_store/faiss_store.py b/metagpt/document_store/faiss_store.py index fbfcb3086..16c152c1c 100644 --- a/metagpt/document_store/faiss_store.py +++ b/metagpt/document_store/faiss_store.py @@ -14,6 +14,7 @@ import faiss from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS +from metagpt.config import CONFIG from metagpt.const import DATA_PATH from metagpt.document_store.base_store import LocalStore from metagpt.document_store.document import Document @@ -21,7 +22,7 @@ from metagpt.logs import logger class FaissStore(LocalStore): - def __init__(self, raw_data: Path, cache_dir=None, meta_col='source', content_col='output'): + def __init__(self, raw_data: Path, cache_dir=None, meta_col="source", content_col="output"): self.meta_col = meta_col self.content_col = content_col super().__init__(raw_data, cache_dir) @@ -37,11 +38,12 @@ class FaissStore(LocalStore): store.index = index return store - def _write(self, docs, metadatas, **kwargs): - store = FAISS.from_texts(docs, - OpenAIEmbeddings(openai_api_version="2020-11-07", - openai_api_key=kwargs.get("OPENAI_API_KEY")), - metadatas=metadatas) + def _write(self, docs, metadatas): + store = FAISS.from_texts( + docs, + OpenAIEmbeddings(openai_api_version="2020-11-07", openai_api_key=CONFIG.OPENAI_API_KEY), + metadatas=metadatas, + ) return store def persist(self): @@ -54,7 +56,7 @@ class FaissStore(LocalStore): pickle.dump(store, f) store.index = index - def search(self, query, expand_cols=False, sep='\n', *args, k=5, **kwargs): + def search(self, query, expand_cols=False, sep="\n", *args, k=5, **kwargs): rsp = self.store.similarity_search(query, k=k, **kwargs) logger.debug(rsp) if expand_cols: @@ -82,8 +84,8 @@ class FaissStore(LocalStore): raise NotImplementedError -if __name__ == '__main__': - faiss_store = FaissStore(DATA_PATH / 'qcs/qcs_4w.json') - logger.info(faiss_store.search('油皮洗面奶')) - faiss_store.add([f'油皮洗面奶-{i}' for i in range(3)]) - logger.info(faiss_store.search('油皮洗面奶')) +if __name__ == "__main__": + faiss_store = FaissStore(DATA_PATH / "qcs/qcs_4w.json") + logger.info(faiss_store.search("油皮洗面奶")) + faiss_store.add([f"油皮洗面奶-{i}" for i in range(3)]) + logger.info(faiss_store.search("油皮洗面奶")) diff --git a/metagpt/memory/longterm_memory.py b/metagpt/memory/longterm_memory.py index 041d335ac..df748037a 100644 --- a/metagpt/memory/longterm_memory.py +++ b/metagpt/memory/longterm_memory.py @@ -37,13 +37,13 @@ class LongTermMemory(Memory): self.add_batch(messages) self.msg_from_recover = False - def add(self, message: Message, **kwargs): + def add(self, message: Message): super(LongTermMemory, self).add(message) for action in self.rc.watch: if message.cause_by == action and not self.msg_from_recover: # currently, only add role's watching messages to its memory_storage # and ignore adding messages from recover repeatedly - self.memory_storage.add(message, **kwargs) + self.memory_storage.add(message) def remember(self, observed: list[Message], k=0) -> list[Message]: """ diff --git a/metagpt/memory/memory_storage.py b/metagpt/memory/memory_storage.py index 09cd67410..9afd524f0 100644 --- a/metagpt/memory/memory_storage.py +++ b/metagpt/memory/memory_storage.py @@ -5,16 +5,16 @@ @Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation. """ -from typing import List from pathlib import Path +from typing import List from langchain.vectorstores.faiss import FAISS from metagpt.const import DATA_PATH, MEM_TTL +from metagpt.document_store.faiss_store import FaissStore from metagpt.logs import logger from metagpt.schema import Message -from metagpt.utils.serialize import serialize_message, deserialize_message -from metagpt.document_store.faiss_store import FaissStore +from metagpt.utils.serialize import deserialize_message, serialize_message class MemoryStorage(FaissStore): @@ -37,7 +37,7 @@ class MemoryStorage(FaissStore): def recover_memory(self, role_id: str) -> List[Message]: self.role_id = role_id - self.role_mem_path = Path(DATA_PATH / f'role_mem/{self.role_id}/') + self.role_mem_path = Path(DATA_PATH / f"role_mem/{self.role_id}/") self.role_mem_path.mkdir(parents=True, exist_ok=True) self.store = self._load() @@ -54,23 +54,23 @@ class MemoryStorage(FaissStore): def _get_index_and_store_fname(self): if not self.role_mem_path: - logger.error(f'You should call {self.__class__.__name__}.recover_memory fist when using LongTermMemory') + logger.error(f"You should call {self.__class__.__name__}.recover_memory fist when using LongTermMemory") return None, None - index_fpath = Path(self.role_mem_path / f'{self.role_id}.index') - storage_fpath = Path(self.role_mem_path / f'{self.role_id}.pkl') + index_fpath = Path(self.role_mem_path / f"{self.role_id}.index") + storage_fpath = Path(self.role_mem_path / f"{self.role_id}.pkl") return index_fpath, storage_fpath def persist(self): super(MemoryStorage, self).persist() - logger.debug(f'Agent {self.role_id} persist memory into local') + logger.debug(f"Agent {self.role_id} persist memory into local") - def add(self, message: Message, **kwargs) -> bool: - """ add message into memory storage""" + def add(self, message: Message) -> bool: + """add message into memory storage""" docs = [message.content] metadatas = [{"message_ser": serialize_message(message)}] if not self.store: # init Faiss - self.store = self._write(docs, metadatas, **kwargs) + self.store = self._write(docs, metadatas) self._initialized = True else: self.store.add_texts(texts=docs, metadatas=metadatas) @@ -82,10 +82,7 @@ class MemoryStorage(FaissStore): if not self.store: return [] - resp = self.store.similarity_search_with_score( - query=message.content, - k=k - ) + resp = self.store.similarity_search_with_score(query=message.content, k=k) # filter the result which score is smaller than the threshold filtered_resp = [] for item, score in resp: diff --git a/tests/metagpt/memory/test_longterm_memory.py b/tests/metagpt/memory/test_longterm_memory.py index 457e665fa..b77e9a955 100644 --- a/tests/metagpt/memory/test_longterm_memory.py +++ b/tests/metagpt/memory/test_longterm_memory.py @@ -4,11 +4,11 @@ @Desc : unittest of `metagpt/memory/longterm_memory.py` @Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation. """ -from metagpt.config import Config -from metagpt.schema import Message from metagpt.actions import BossRequirement -from metagpt.roles.role import RoleContext +from metagpt.config import Config from metagpt.memory import LongTermMemory +from metagpt.roles.role import RoleContext +from metagpt.schema import Message def test_ltm_search(): @@ -17,28 +17,28 @@ def test_ltm_search(): openai_api_key = conf.openai_api_key assert len(openai_api_key) > 20 - role_id = 'UTUserLtm(Product Manager)' - rc = RoleContext(options=conf.runtime_options, watch=[BossRequirement]) + role_id = "UTUserLtm(Product Manager)" + rc = RoleContext(watch=[BossRequirement]) ltm = LongTermMemory() ltm.recover_memory(role_id, rc) - idea = 'Write a cli snake game' - message = Message(role='BOSS', content=idea, cause_by=BossRequirement) + idea = "Write a cli snake game" + message = Message(role="BOSS", content=idea, cause_by=BossRequirement) news = ltm.remember([message]) assert len(news) == 1 - ltm.add(message, **conf.runtime_options) + ltm.add(message) - sim_idea = 'Write a game of cli snake' - sim_message = Message(role='BOSS', content=sim_idea, cause_by=BossRequirement) + sim_idea = "Write a game of cli snake" + sim_message = Message(role="BOSS", content=sim_idea, cause_by=BossRequirement) news = ltm.remember([sim_message]) assert len(news) == 0 - ltm.add(sim_message, **conf.runtime_options) + ltm.add(sim_message) - new_idea = 'Write a 2048 web game' - new_message = Message(role='BOSS', content=new_idea, cause_by=BossRequirement) + new_idea = "Write a 2048 web game" + new_message = Message(role="BOSS", content=new_idea, cause_by=BossRequirement) news = ltm.remember([new_message]) assert len(news) == 1 - ltm.add(new_message, **conf.runtime_options) + ltm.add(new_message) # restore from local index ltm_new = LongTermMemory() @@ -50,8 +50,8 @@ def test_ltm_search(): news = ltm_new.remember([sim_message]) assert len(news) == 0 - new_idea = 'Write a Battle City' - new_message = Message(role='BOSS', content=new_idea, cause_by=BossRequirement) + new_idea = "Write a Battle City" + new_message = Message(role="BOSS", content=new_idea, cause_by=BossRequirement) news = ltm_new.remember([new_message]) assert len(news) == 1 From 53030428c357ceda1ae11f830d850d9ea2e977d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 13:22:57 +0800 Subject: [PATCH 07/12] =?UTF-8?q?revert:=20=E6=94=B9=E7=94=A8CONFIG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/talk_action.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index c314b500d..e7b3d84c8 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -75,7 +75,6 @@ class TalkAction(Action): "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; "Constraint" defines the conditions that your responses must comply with. “Personality” defines your language style。 - "Command" defines the action to do when command keyword is entered. "Insight" provides a deeper understanding of the characters' inner traits. "Initial" defines the initial setup of a character. @@ -116,7 +115,6 @@ Statement: Unless you are a language professional, answer the following question "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; "Constraint" defines the conditions that your responses must comply with. “Personality” defines your language style。 - "Command" defines the action to do when command keyword is entered. "Insight" provides a deeper understanding of the characters' inner traits. "Initial" defines the initial setup of a character. From fa7e16192a76f1dc68374ae6f2767f2150b5a690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 13:28:28 +0800 Subject: [PATCH 08/12] =?UTF-8?q?revert:=20=E6=94=B9=E7=94=A8CONFIG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/talk_action.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index e7b3d84c8..55e6e1aaa 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -72,7 +72,7 @@ class TalkAction(Action): "[HISTORY_BEGIN]" and "[HISTORY_END]" tags enclose the historical conversation; "[KNOWLEDGE_BEGIN]" and "[KNOWLEDGE_END]" tags enclose the knowledge may help for your responses; "Statement" defines the work detail you need to complete at this stage; - "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; + "[ASK_BEGIN]" and [ASK_END] tags enclose the questions; "Constraint" defines the conditions that your responses must comply with. “Personality” defines your language style。 "Insight" provides a deeper understanding of the characters' inner traits. @@ -112,7 +112,7 @@ Statement: Unless you are a language professional, answer the following question "[HISTORY_BEGIN]" and "[HISTORY_END]" tags enclose the historical conversation; "[KNOWLEDGE_BEGIN]" and "[KNOWLEDGE_END]" tags enclose the knowledge may help for your responses; "Statement" defines the work detail you need to complete at this stage; - "[ASK_BEGIN]" and [ASK_END] tags enclose the requirements for your to respond; + "[ASK_BEGIN]" and [ASK_END] tags enclose the questions; "Constraint" defines the conditions that your responses must comply with. “Personality” defines your language style。 "Insight" provides a deeper understanding of the characters' inner traits. From 6b59f28eb35ca7b975c3cfd4bbb38f900ea6bd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 13:34:57 +0800 Subject: [PATCH 09/12] =?UTF-8?q?revert:=20=E6=94=B9=E7=94=A8CONFIG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/talk_action.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/actions/talk_action.py b/metagpt/actions/talk_action.py index 55e6e1aaa..6ec64d7f9 100644 --- a/metagpt/actions/talk_action.py +++ b/metagpt/actions/talk_action.py @@ -74,7 +74,7 @@ class TalkAction(Action): "Statement" defines the work detail you need to complete at this stage; "[ASK_BEGIN]" and [ASK_END] tags enclose the questions; "Constraint" defines the conditions that your responses must comply with. - “Personality” defines your language style。 + "Personality" defines your language style。 "Insight" provides a deeper understanding of the characters' inner traits. "Initial" defines the initial setup of a character. @@ -114,7 +114,7 @@ Statement: Unless you are a language professional, answer the following question "Statement" defines the work detail you need to complete at this stage; "[ASK_BEGIN]" and [ASK_END] tags enclose the questions; "Constraint" defines the conditions that your responses must comply with. - “Personality” defines your language style。 + "Personality" defines your language style。 "Insight" provides a deeper understanding of the characters' inner traits. "Initial" defines the initial setup of a character. From 280fd62c94b8f19da3524dc398cdc879ae9e7456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 14:08:00 +0800 Subject: [PATCH 10/12] revert: faiss store --- metagpt/document_store/faiss_store.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metagpt/document_store/faiss_store.py b/metagpt/document_store/faiss_store.py index 16c152c1c..46b959d81 100644 --- a/metagpt/document_store/faiss_store.py +++ b/metagpt/document_store/faiss_store.py @@ -14,7 +14,6 @@ import faiss from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import FAISS -from metagpt.config import CONFIG from metagpt.const import DATA_PATH from metagpt.document_store.base_store import LocalStore from metagpt.document_store.document import Document @@ -41,7 +40,7 @@ class FaissStore(LocalStore): def _write(self, docs, metadatas): store = FAISS.from_texts( docs, - OpenAIEmbeddings(openai_api_version="2020-11-07", openai_api_key=CONFIG.OPENAI_API_KEY), + OpenAIEmbeddings(openai_api_version="2020-11-07"), metadatas=metadatas, ) return store From b9e3886e3012c8fe7f343d6bd165a861addfc43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 14:08:29 +0800 Subject: [PATCH 11/12] revert: faiss store --- metagpt/document_store/faiss_store.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/metagpt/document_store/faiss_store.py b/metagpt/document_store/faiss_store.py index 46b959d81..55c07b920 100644 --- a/metagpt/document_store/faiss_store.py +++ b/metagpt/document_store/faiss_store.py @@ -38,11 +38,7 @@ class FaissStore(LocalStore): return store def _write(self, docs, metadatas): - store = FAISS.from_texts( - docs, - OpenAIEmbeddings(openai_api_version="2020-11-07"), - metadatas=metadatas, - ) + store = FAISS.from_texts(docs, OpenAIEmbeddings(openai_api_version="2020-11-07"), metadatas=metadatas) return store def persist(self): From e7ffd6dbc5ef4cef7036edff6178e2a6db27f450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Tue, 5 Sep 2023 14:11:24 +0800 Subject: [PATCH 12/12] revert: faiss store --- metagpt/document_store/faiss_store.py | 1 - 1 file changed, 1 deletion(-) diff --git a/metagpt/document_store/faiss_store.py b/metagpt/document_store/faiss_store.py index 55c07b920..7833bc706 100644 --- a/metagpt/document_store/faiss_store.py +++ b/metagpt/document_store/faiss_store.py @@ -4,7 +4,6 @@ @Time : 2023/5/25 10:20 @Author : alexanderwu @File : faiss_store.py -@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation. """ import pickle from pathlib import Path