Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

feat: + annotations

莘权 马27561765cf49
diff --git a/metagpt/const.py b/metagpt/const.py
index a14dbc5b8..8c1460a02 100644
--- a/metagpt/const.py
+++ b/metagpt/const.py
@@ -4,7 +4,7 @@
@Time : 2023/5/1 11:59
@Author : alexanderwu
@File : const.py'
-@Modified By: mashenquan, 2023/8/28. Add 'OPTIONS', 'DEFAULT_LANGUAGE'
+@Modified By: mashenquan, 2023/8/28. Add 'OPTIONS', 'DEFAULT_LANGUAGE', 'DEFAULT_MAX_TOKENS'
"""
import contextvars
from pathlib import Path
@@ -40,3 +40,4 @@ MEM_TTL = 24 * 30 * 3600
OPTIONS = contextvars.ContextVar("OPTIONS")
DEFAULT_LANGUAGE = "English"
+DEFAULT_MAX_TOKENS = 1500
\ No newline at end of file
diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py
index 45e67739b..7dba00530 100644
--- a/metagpt/provider/openai_api.py
+++ b/metagpt/provider/openai_api.py
@@ -19,7 +19,7 @@ from pydantic import BaseModel
from tenacity import retry, stop_after_attempt, after_log, wait_fixed, retry_if_exception_type
from metagpt.config import CONFIG
-from metagpt.const import DEFAULT_LANGUAGE
+from metagpt.const import DEFAULT_LANGUAGE, DEFAULT_MAX_TOKENS
from metagpt.logs import logger
from metagpt.provider.base_gpt_api import BaseGPTAPI
from metagpt.utils.token_counter import (
@@ -303,7 +303,7 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter):
async def get_context_title(self, text: str, max_token_count_per_ask=None, max_words=5) -> str:
"""Generate text title"""
max_response_token_count = 50
- max_token_count = max_token_count_per_ask or CONFIG.MAX_TOKENS or 1500
+ max_token_count = max_token_count_per_ask or CONFIG.MAX_TOKENS or DEFAULT_MAX_TOKENS
text_windows = self.split_texts(text, window_size=max_token_count - max_response_token_count)
summaries = []