🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fixbug: METAGPT model is None
莘权 马525c62b2358b
diff --git a/metagpt/provider/metagpt_api.py b/metagpt/provider/metagpt_api.pyindex 69aa7f305..f3dd14bbc 100644--- a/metagpt/provider/metagpt_api.py+++ b/metagpt/provider/metagpt_api.py@@ -5,12 +5,30 @@@File : metagpt_api.py@Desc : MetaGPT LLM provider."""-from metagpt.config import LLMProviderEnum+from openai.types import CompletionUsage++from metagpt.config import CONFIG, LLMProviderEnumfrom metagpt.provider import OpenAILLMfrom metagpt.provider.llm_provider_registry import register_provider+from metagpt.utils.exceptions import handle_exception@register_provider(LLMProviderEnum.METAGPT)class MetaGPTLLM(OpenAILLM):def __init__(self):super().__init__()+ self.model = CONFIG.DEPLOYMENT_NAME++ def _calc_usage(self, messages: list[dict], rsp: str) -> CompletionUsage:+ usage = CompletionUsage(prompt_tokens=0, completion_tokens=0, total_tokens=0)+ if not CONFIG.calc_usage:+ return usage++ # The current billing is based on usage frequency. If there is a future billing logic based on the+ # number of tokens, please refine the logic here accordingly.++ return usage++ @handle_exception+ def _update_costs(self, usage: CompletionUsage):+ passdiff --git a/metagpt/utils/cost_manager.py b/metagpt/utils/cost_manager.pyindex ce53f2285..e6d51e641 100644--- a/metagpt/utils/cost_manager.py+++ b/metagpt/utils/cost_manager.py@@ -39,6 +39,8 @@ class CostManager(BaseModel):completion_tokens (int): The number of tokens used in the completion.model (str): The model used for the API call."""+ if prompt_tokens + completion_tokens == 0:+ returnself.total_prompt_tokens += prompt_tokensself.total_completion_tokens += completion_tokenscost = (diff --git a/setup.py b/setup.pyindex 235c18f53..83bdcce9a 100644--- a/setup.py+++ b/setup.py@@ -57,7 +57,7 @@ extras_require["dev"] = (["pylint~=3.0.3", "black~=23.3.0", "isort~=5.12.0", "prsetup(name="metagpt",- version="0.6.8",+ version="0.6.9",description="The Multi-Agent Framework",long_description=long_description,long_description_content_type="text/markdown",