Skip to content

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

Merge branch 'main' into dev

geekan6707e9f1b9eb
diff --cc metagpt/actions/research.py
index a1535a723,5057c3d3a..b52d99d6f
--- a/metagpt/actions/research.py
+++ b/metagpt/actions/research.py
@@@ -82,11 -82,10 +82,11 @@@ class CollectLinks(Action)
name: str = "CollectLinks"
context: Optional[str] = None
- llm: BaseGPTAPI = Field(default_factory=LLM)
+ llm: BaseLLM = Field(default_factory=LLM)
desc: str = "Collect links from a search engine."
+
search_engine: SearchEngine = Field(default_factory=SearchEngine)
- rank_func: Union[Callable[[list[str]], None], None] = None
+ rank_func: Optional[Callable[[list[str]], None]] = None
async def run(
self,
@@@ -178,15 -177,10 +178,10 @@@ class WebBrowseAndSummarize(Action)
name: str = "WebBrowseAndSummarize"
context: Optional[str] = None
- llm: BaseGPTAPI = Field(default_factory=LLM)
+ llm: BaseLLM = Field(default_factory=LLM)
desc: str = "Explore the web and provide summaries of articles and webpages."
browse_func: Union[Callable[[list[str]], None], None] = None
- web_browser_engine: WebBrowserEngine = Field(
- default_factory=lambda: WebBrowserEngine(
- engine=WebBrowserEngineType.CUSTOM if WebBrowseAndSummarize.browse_func else None,
- run_func=WebBrowseAndSummarize.browse_func,
- )
- )
+ web_browser_engine: Optional[WebBrowserEngine] = None
def __init__(self, **kwargs):
super().__init__(**kwargs)
diff --cc tests/metagpt/provider/test_zhipuai_api.py
index 06f2cba62,8ce0f8f63..fca45ba18
--- a/tests/metagpt/provider/test_zhipuai_api.py
+++ b/tests/metagpt/provider/test_zhipuai_api.py
@@@ -30,29 -29,14 +30,30 @@@ async def mock_llm_achat_completion_str
@pytest.mark.asyncio
async def test_zhipuai_acompletion(mocker):
- mocker.patch("metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI.acompletion_text", mock_llm_aask)
+ mocker.patch("metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI.acompletion", mock_llm_acompletion)
+ mocker.patch("metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI._achat_completion", mock_llm_acompletion)
+ mocker.patch(
+ "metagpt.provider.zhipuai_api.ZhiPuAIGPTAPI._achat_completion_stream", mock_llm_achat_completion_stream
+ )
+ zhipu_gpt = ZhiPuAIGPTAPI()
+
+ resp = await zhipu_gpt.acompletion(messages)
+ assert resp["data"]["choices"][0]["content"] == resp_content
+
+ resp = await zhipu_gpt.aask(prompt_msg, stream=False)
+ assert resp == resp_content
+
+ resp = await zhipu_gpt.acompletion_text(messages, stream=False)
+ assert resp == resp_content
+
+ resp = await zhipu_gpt.acompletion_text(messages, stream=True)
+ assert resp == resp_content
- resp = await ZhiPuAIGPTAPI().acompletion_text(messages, stream=False)
+ resp = await zhipu_gpt.aask(prompt_msg)
+ assert resp == resp_content
- assert resp["code"] == 200
- assert "chatglm-turbo" in resp["data"]["choices"][0]["content"]
+
def test_zhipuai_proxy(mocker):
import openai