🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fix research bugs
shenchuchengd94f4fbfbc3b
diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.pyindex 63e68c9bd..7b2cd6220 100644--- a/metagpt/provider/openai_api.py+++ b/metagpt/provider/openai_api.py@@ -253,7 +253,9 @@ class OpenAILLM(BaseLLM):def _get_max_tokens(self, messages: list[dict]):if not self.auto_max_tokens:return self.config.max_token- return get_max_completion_tokens(messages, self.model, self.config.max_tokens)+ # FIXME+ # https://community.openai.com/t/why-is-gpt-3-5-turbo-1106-max-tokens-limited-to-4096/494973/3+ return min(get_max_completion_tokens(messages, self.model, self.config.max_tokens), 4096)@handle_exceptionasync def amoderation(self, content: Union[str, list[str]]):diff --git a/metagpt/utils/text.py b/metagpt/utils/text.pyindex 921efe706..fb8b94232 100644--- a/metagpt/utils/text.py+++ b/metagpt/utils/text.py@@ -93,7 +93,7 @@ def split_paragraph(paragraph: str, sep: str = ".,", count: int = 2) -> list[strcontinueret = ["".join(j) for j in _split_by_count(sentences, count)]return ret- return _split_by_count(paragraph, count)+ return list(_split_by_count(paragraph, count))def decode_unicode_escape(text: str) -> str:diff --git a/tests/metagpt/utils/test_text.py b/tests/metagpt/utils/test_text.pyindex 7003c7767..c9a9753be 100644--- a/tests/metagpt/utils/test_text.py+++ b/tests/metagpt/utils/test_text.py@@ -42,6 +42,7 @@ def test_reduce_message_length(msgs, model_name, system_text, reserved, expected(" ".join("Hello World." for _ in range(1000)), "Prompt: {}", "gpt-3.5-turbo-16k", "System", 3000, 1),(" ".join("Hello World." for _ in range(4000)), "Prompt: {}", "gpt-4", "System", 2000, 2),(" ".join("Hello World." for _ in range(8000)), "Prompt: {}", "gpt-4-32k", "System", 4000, 1),+ (" ".join("Hello World" for _ in range(8000)), "Prompt: {}", "gpt-3.5-turbo", "System", 1000, 8),],)def test_generate_prompt_chunk(text, prompt_template, model_name, system_text, reserved, expected):