From ac4eb309c3867877711347b58b9678323de8ae53 Mon Sep 17 00:00:00 2001 From: voidking Date: Sun, 20 Oct 2024 15:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4codecov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fulltest.yaml | 10 +++---- .github/workflows/unittest.yaml | 10 +++---- metagpt/provider/bedrock/bedrock_provider.py | 26 +++---------------- metagpt/provider/bedrock/utils.py | 2 +- metagpt/provider/bedrock_api.py | 2 +- metagpt/rag/factories/index.py | 2 +- metagpt/rag/factories/retriever.py | 4 ++- metagpt/rag/retrievers/milvus_retriever.py | 2 +- metagpt/rag/schema.py | 3 ++- milvus_local.db | Bin 0 -> 12288 bytes tests/metagpt/rag/factories/test_index.py | 3 ++- 11 files changed, 25 insertions(+), 39 deletions(-) create mode 100644 milvus_local.db diff --git a/.github/workflows/fulltest.yaml b/.github/workflows/fulltest.yaml index 2ab6444fa..32eb3da00 100644 --- a/.github/workflows/fulltest.yaml +++ b/.github/workflows/fulltest.yaml @@ -79,8 +79,8 @@ jobs: ./tests/data/rsp_cache_new.json retention-days: 3 if: ${{ always() }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: ${{ always() }} + # - name: Upload coverage reports to Codecov + # uses: codecov/codecov-action@v3 + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + # if: ${{ always() }} diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index 25f82b1e6..1fd193b52 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -91,8 +91,8 @@ jobs: ./tests/data/rsp_cache_new.json retention-days: 3 if: ${{ always() }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: ${{ always() }} + # - name: Upload coverage reports to Codecov + # uses: codecov/codecov-action@v3 + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + # if: ${{ always() }} diff --git a/metagpt/provider/bedrock/bedrock_provider.py b/metagpt/provider/bedrock/bedrock_provider.py index 90475bf41..c5e3b7bd2 100644 --- a/metagpt/provider/bedrock/bedrock_provider.py +++ b/metagpt/provider/bedrock/bedrock_provider.py @@ -69,19 +69,9 @@ class CohereProvider(BaseBedrockProvider): def messages_to_prompt(self, messages: list[dict]) -> str: if "command-r" in self.model_name: - role_map = { - "user": "USER", - "assistant": "CHATBOT", - "system": "USER" - } + role_map = {"user": "USER", "assistant": "CHATBOT", "system": "USER"} messages = list( - map( - lambda message: { - "role": role_map[message["role"]], - "message": message["content"] - }, - messages - ) + map(lambda message: {"role": role_map[message["role"]], "message": message["content"]}, messages) ) return messages else: @@ -92,17 +82,9 @@ class CohereProvider(BaseBedrockProvider): prompt = self.messages_to_prompt(messages) if "command-r" in self.model_name: chat_history, message = prompt[:-1], prompt[-1]["message"] - body = json.dumps({ - "message": message, - "chat_history": chat_history, - **generate_kwargs - }) + body = json.dumps({"message": message, "chat_history": chat_history, **generate_kwargs}) else: - body = json.dumps({ - "prompt": prompt, - "stream": kwargs.get("stream", False), - **generate_kwargs - }) + body = json.dumps({"prompt": prompt, "stream": kwargs.get("stream", False), **generate_kwargs}) return body def get_choice_text_from_stream(self, event) -> str: diff --git a/metagpt/provider/bedrock/utils.py b/metagpt/provider/bedrock/utils.py index 66e98c759..e67796362 100644 --- a/metagpt/provider/bedrock/utils.py +++ b/metagpt/provider/bedrock/utils.py @@ -91,7 +91,7 @@ SUPPORT_STREAM_MODELS = { # Mistral Large (24.02) "mistral.mistral-large-2402-v1:0": 8192, # Mistral Large 2 (24.07) - "mistral.mistral-large-2407-v1:0": 8192 + "mistral.mistral-large-2407-v1:0": 8192, } # TODO:use a more general function for constructing chat templates. diff --git a/metagpt/provider/bedrock_api.py b/metagpt/provider/bedrock_api.py index 4cf22f41b..4e783f579 100644 --- a/metagpt/provider/bedrock_api.py +++ b/metagpt/provider/bedrock_api.py @@ -1,6 +1,6 @@ -import os import asyncio import json +import os from functools import partial from typing import List, Literal diff --git a/metagpt/rag/factories/index.py b/metagpt/rag/factories/index.py index 6da4900a0..4e6d6b167 100644 --- a/metagpt/rag/factories/index.py +++ b/metagpt/rag/factories/index.py @@ -30,7 +30,7 @@ class RAGIndexFactory(ConfigBasedFactory): BM25IndexConfig: self._create_bm25, ElasticsearchIndexConfig: self._create_es, ElasticsearchKeywordIndexConfig: self._create_es, - MilvusIndexConfig: self._create_milvus + MilvusIndexConfig: self._create_milvus, } super().__init__(creators) diff --git a/metagpt/rag/factories/retriever.py b/metagpt/rag/factories/retriever.py index 3342b8905..490df4906 100644 --- a/metagpt/rag/factories/retriever.py +++ b/metagpt/rag/factories/retriever.py @@ -139,7 +139,9 @@ class RetrieverFactory(ConfigBasedFactory): @get_or_build_index def _build_milvus_index(self, config: MilvusRetrieverConfig, **kwargs) -> VectorStoreIndex: - vector_store = MilvusVectorStore(uri=config.uri, collection_name=config.collection_name, token=config.token, dim=config.dimensions) + vector_store = MilvusVectorStore( + uri=config.uri, collection_name=config.collection_name, token=config.token, dim=config.dimensions + ) return self._build_index_from_vector_store(config, vector_store, **kwargs) diff --git a/metagpt/rag/retrievers/milvus_retriever.py b/metagpt/rag/retrievers/milvus_retriever.py index ff2562bd8..bcc66330b 100644 --- a/metagpt/rag/retrievers/milvus_retriever.py +++ b/metagpt/rag/retrievers/milvus_retriever.py @@ -14,4 +14,4 @@ class MilvusRetriever(VectorIndexRetriever): def persist(self, persist_dir: str, **kwargs) -> None: """Support persist. - Milvus automatically saves, so there is no need to implement.""" \ No newline at end of file + Milvus automatically saves, so there is no need to implement.""" diff --git a/metagpt/rag/schema.py b/metagpt/rag/schema.py index e4d97068d..1e04a546f 100644 --- a/metagpt/rag/schema.py +++ b/metagpt/rag/schema.py @@ -8,7 +8,7 @@ from llama_index.core.embeddings import BaseEmbedding from llama_index.core.indices.base import BaseIndex from llama_index.core.schema import TextNode from llama_index.core.vector_stores.types import VectorStoreQueryMode -from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, model_validator, validator +from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, model_validator from metagpt.config2 import config from metagpt.configs.embedding_config import EmbeddingType @@ -199,6 +199,7 @@ class ChromaIndexConfig(VectorIndexConfig): default=None, description="Optional metadata to associate with the collection" ) + class MilvusIndexConfig(VectorIndexConfig): """Config for milvus-based index.""" diff --git a/milvus_local.db b/milvus_local.db new file mode 100644 index 0000000000000000000000000000000000000000..fdc101fa47981add08b0cd1bbef4558e70c90616 GIT binary patch literal 12288 zcmeI%%Wl&^6b4|AO)fPeO^r$@uo!veq!CKf3T26tS`d+@;2K0%krPkaLB3Rpo3=|M zA+ct|8z8ZTSKuAGhsTT#qfy|-bXzJ)ghnWVfs#K*_P>8)G?bKi|Xm5P7UtScGt09ST=oa zxA#o@kiN1Gt2E&L362xdTH9mR;|8Mu2Rp9UE1vIH_M4da;42p@^N0p;HrXN zz+!jlR!-Hil)Sl&YZF5^V9Ui!7wW|qCx0dSe$?*`IrF_)tyMaXM?5@QJW731dET2} zN~<3Vm$%}_BnUtN0uX=z1Rwwb2tWV=5P-nHBajs3oK!9)!A832=b^{W^Q`#w*QeiK zet!F&eUzPuor7pp$*E*dleZd`b+y2Tttb>t^XY6)K~w5GwMt1Zf(VU>+H9? zyViR#|E}o7M|?2PWLx_O?XFeHtBS`1jWlXxzCv=Jh>|vvi?wt~1$fXj?UV