From a93090881363c5265b67577631d1074c9b6de5cd Mon Sep 17 00:00:00 2001 From: Xuchen Pan <32844285+pan-x-c@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:48:58 +0800 Subject: [PATCH] Update sphinx doc for v0.0.2 (#125) --- README.md | 4 +- README_ZH.md | 4 +- .../en/source/agentscope.models.rst | 24 +++++++++++ .../source/agentscope.service.web_search.rst | 7 ++++ .../en/source/tutorial/102-installation.md | 2 +- .../en/source/tutorial/104-usecase.md | 9 ++--- .../en/source/tutorial/201-agent.md | 15 ++++--- .../en/source/tutorial/204-service.md | 40 ++++++++++--------- .../en/source/tutorial/302-contribute.md | 4 +- .../zh_CN/source/agentscope.models.rst | 24 +++++++++++ .../source/agentscope.service.web_search.rst | 7 ++++ .../zh_CN/source/tutorial/102-installation.md | 2 +- .../zh_CN/source/tutorial/104-usecase.md | 6 +-- .../zh_CN/source/tutorial/201-agent.md | 15 ++++--- .../zh_CN/source/tutorial/204-service.md | 40 ++++++++++--------- .../zh_CN/source/tutorial/302-contribute.md | 4 +- setup.py | 1 + src/agentscope/agents/text_to_image_agent.py | 2 +- src/agentscope/models/dashscope_model.py | 4 +- src/agentscope/models/post_model.py | 4 +- .../service/web_search/web_digest.py | 26 ++++++++---- 21 files changed, 164 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 91367b4cc..2f1340b21 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ the following libraries. - Distribution - [Distributed Conversation](./examples/distributed_basic) - [Distributed Debate](./examples/distributed_debate) - - [Distributed Search](./examples/distributed_search) + - [Distributed Parallel Search](./examples/distributed_search) More models, services and examples are coming soon! @@ -136,7 +136,7 @@ install AgentScope from source._** git clone https://github.com/modelscope/agentscope.git # Install the package in editable mode -cd AgentScope +cd agentscope pip install -e . ``` diff --git a/README_ZH.md b/README_ZH.md index 44f6fb5d2..82663e3c0 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -104,7 +104,7 @@ AgentScope支持使用以下库快速部署本地模型服务。 - 分布式 - [分布式对话](./examples/distributed_basic) - [分布式辩论](./examples/distributed_debate) - - [分布式搜索](./examples/distributed_search) + - [分布式并行搜索](./examples/distributed_search) 更多模型API、服务和示例即将推出! @@ -122,7 +122,7 @@ AgentScope需要Python 3.9或更高版本。 # 从github拉取源代码 git clone https://github.com/modelscope/agentscope.git # 以编辑模式安装包 -cd AgentScope +cd agentscope pip install -e . ``` diff --git a/docs/sphinx_doc/en/source/agentscope.models.rst b/docs/sphinx_doc/en/source/agentscope.models.rst index a61cbdfaa..3ce904d54 100644 --- a/docs/sphinx_doc/en/source/agentscope.models.rst +++ b/docs/sphinx_doc/en/source/agentscope.models.rst @@ -17,6 +17,14 @@ model module :undoc-members: :show-inheritance: +dashscope\_model module +--------------------------------------- + +.. automodule:: agentscope.models.dashscope_model + :members: + :undoc-members: + :show-inheritance: + openai\_model module --------------------------------------- @@ -25,6 +33,22 @@ openai\_model module :undoc-members: :show-inheritance: +ollama\_model module +--------------------------------------- + +.. automodule:: agentscope.models.ollama_model + :members: + :undoc-members: + :show-inheritance: + +gemini\_model module +--------------------------------------- + +.. automodule:: agentscope.models.gemini_model + :members: + :undoc-members: + :show-inheritance: + post\_model module ------------------------------------- diff --git a/docs/sphinx_doc/en/source/agentscope.service.web_search.rst b/docs/sphinx_doc/en/source/agentscope.service.web_search.rst index 895ab915c..d2ef72a9a 100644 --- a/docs/sphinx_doc/en/source/agentscope.service.web_search.rst +++ b/docs/sphinx_doc/en/source/agentscope.service.web_search.rst @@ -9,3 +9,10 @@ search module :undoc-members: :show-inheritance: +web\_digest module +--------------------------------------------- + +.. automodule:: agentscope.service.web_search.web_digest + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/sphinx_doc/en/source/tutorial/102-installation.md b/docs/sphinx_doc/en/source/tutorial/102-installation.md index 51473c659..2a68124f4 100644 --- a/docs/sphinx_doc/en/source/tutorial/102-installation.md +++ b/docs/sphinx_doc/en/source/tutorial/102-installation.md @@ -55,7 +55,7 @@ For users who prefer to install AgentScope directly from the source code, follow ```bash # Pull the source code from Github git clone https://github.com/modelscope/agentscope.git -cd AgentScope +cd agentscope # For centralized multi-agent applications pip install -e . diff --git a/docs/sphinx_doc/en/source/tutorial/104-usecase.md b/docs/sphinx_doc/en/source/tutorial/104-usecase.md index 15ad7982c..0b9009e3b 100644 --- a/docs/sphinx_doc/en/source/tutorial/104-usecase.md +++ b/docs/sphinx_doc/en/source/tutorial/104-usecase.md @@ -14,7 +14,7 @@ Let the adventure begin to unlock the potential of multi-agent applications with Firstly, ensure that you have installed and configured AgentScope properly. Besides, we will involve the basic concepts of `Model API`, `Agent`, `Msg`, and `Pipeline,` as described in [Tutorial-Concept](101-agentscope). -**Note**: all the configurations and code for this tutorial can be found in `examples/werewolf`. +**Note**: all the configurations and code for this tutorial can be found in `examples/game_werewolf`. ### Step 1: Prepare Model API and Set Model Configs @@ -72,7 +72,7 @@ AgentScope provides several out-of-the-box Agents implements and organizes them In this configuration, `Player1` is designated as a `DictDialogAgent`. The parameters include a system prompt (`sys_prompt`) that can guide the agent's behavior, a model config name (`model_config_name`) that determines the name of the model configuration, and a flag (`use_memory`) indicating whether the agent should remember past interactions. -For other players, configurations can be customized based on their roles. Each role may have different prompts, models, or memory settings. You can refer to the JSON file located at `examples/werewolf/configs/agent_configs.json` within the AgentScope examples directory. +For other players, configurations can be customized based on their roles. Each role may have different prompts, models, or memory settings. You can refer to the JSON file located at `examples/game_werewolf/configs/agent_configs.json` within the AgentScope examples directory. ### Step 3: Initialize AgentScope and the Agents @@ -153,7 +153,7 @@ for i in range(1, MAX_GAME_ROUND + 1): After the discussion, werewolves proceed to vote for their target, and the majority's choice is determined. The result of the vote is then broadcast to all werewolves. -**Note**: the detailed prompts and utility functions can be found in `examples/werewolf`. +**Note**: the detailed prompts and utility functions can be found in `examples/game_werewolf`. ```python # werewolves vote @@ -262,7 +262,7 @@ These code blocks outline the core game loop for Werewolf using AgentScope's `ms With the game logic and agents set up, you're ready to run the Werewolf game. By executing the `pipeline`, the game will proceed through the predefined phases, with agents interacting based on their roles and the strategies coded above: ```bash -cd examples/werewolf +cd examples/game_werewolf python main.py # Assuming the pipeline is implemented in main.py ``` @@ -308,5 +308,4 @@ Moderator: The day is coming, all the players open your eyes. Last night is peac Now you've grasped how to conveniently set up a multi-agent application with AgentScope. Feel free to tailor the game to include additional roles and introduce more sophisticated strategies. For more advanced tutorials that delve deeper into more capabilities of AgentScope, such as *memory management* and *service functions* utilized by agents, please refer to the tutorials in the **Advanced Exploration** section and look up the API references. - [[Return to the top]](#104-usecase-en) diff --git a/docs/sphinx_doc/en/source/tutorial/201-agent.md b/docs/sphinx_doc/en/source/tutorial/201-agent.md index 3b1a73d9f..a30c2153c 100644 --- a/docs/sphinx_doc/en/source/tutorial/201-agent.md +++ b/docs/sphinx_doc/en/source/tutorial/201-agent.md @@ -62,12 +62,15 @@ The *AgentPool* within AgentScope is a curated ensemble of ready-to-use, special Below is a table summarizing the functionality of some of the key agents available in the Agent Pool: -| Agent Type | Description | Typical Use Cases | -| -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `AgentBase` | Serves as the superclass for all agents, providing essential attributes and methods. | The foundation for building any custom agent. | -| `DialogAgent` | Manages dialogues by understanding context and generating coherent responses. | Customer service bots, virtual assistants. | -| `UserAgent` | Interacts with the user to collect input, generating messages that may include URLs or additional specifics based on required keys. | Collecting user input for agents | -| *More to Come* | AgentScope is continuously expanding its pool with more specialized agents for diverse applications. | | +| Agent Type | Description | Typical Use Cases | +| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | +| `AgentBase` | Serves as the superclass for all agents, providing essential attributes and methods. | The foundation for building any custom agent. | +| `DialogAgent` | Manages dialogues by understanding context and generating coherent responses. | Customer service bots, virtual assistants. | +| `DictDialogAgent` | Manages dialogues by understanding context and generating coherent responses, and the responses are in json format. | Customer service bots, virtual assistants. | +| `UserAgent` | Interacts with the user to collect input, generating messages that may include URLs or additional specifics based on required keys. | Collecting user input for agents | +| `TextToImageAgent` | An agent that convert user input text to image. | Converting text to image | +| `ReActAgent` | An agent class that implements the ReAct algorithm. | Solving complex tasks | +| *More to Come* | AgentScope is continuously expanding its pool with more specialized agents for diverse applications. | | ## Customizing Agents from the AgentPool diff --git a/docs/sphinx_doc/en/source/tutorial/204-service.md b/docs/sphinx_doc/en/source/tutorial/204-service.md index 660d57c5b..9a79a3121 100644 --- a/docs/sphinx_doc/en/source/tutorial/204-service.md +++ b/docs/sphinx_doc/en/source/tutorial/204-service.md @@ -12,25 +12,27 @@ AgentScope and how to use them to enhance the capabilities of your agents. The following table outlines the various Service functions by type. These functions can be called using `agentscope.service.{function_name}`. -| Service Scene | Service Function Name | Description | -| -------------- | --------------------- | ------------------------------------------------------------ | -| Code | `execute_python_code` | Execute a piece of Python code, optionally inside a Docker container. | -| Retrieval | `retrieve_from_list` | Retrieve a specific item from a list based on given criteria. | -| SQL Query | `query_mysql` | Execute SQL queries on a MySQL database and return results. | -| | `query_sqlite` | Execute SQL queries on a SQLite database and return results. | -| | `query_mongodb` | Perform queries or operations on a MongoDB collection. | -| Text Processing | `summarization` | Summarize a piece of text using a large language model to highlight its main points. | -| Web Search | `web_search` | Perform a web search using a specified search engine (currently supports Google and Bing). | -| File | `create_file` | Create a new file at a specified path, optionally with initial content. | -| | `delete_file` | Delete a file specified by a file path. | -| | `move_file` | Move or rename a file from one path to another. | -| | `create_directory` | Create a new directory at a specified path. | -| | `delete_directory` | Delete a directory and all its contents. | -| | `move_directory` | Move or rename a directory from one path to another. | -| | `read_text_file` | Read and return the content of a text file. | -| | `write_text_file` | Write text content to a file at a specified path. | -| | `read_json_file` | Read and parse the content of a JSON file. | -| | `write_json_file` | Serialize a Python object to JSON and write to a file. | +| Service Scene | Service Function Name | Description | +| --------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------- | +| Code | `execute_python_code` | Execute a piece of Python code, optionally inside a Docker container. | +| Retrieval | `retrieve_from_list` | Retrieve a specific item from a list based on given criteria. | +| SQL Query | `query_mysql` | Execute SQL queries on a MySQL database and return results. | +| | `query_sqlite` | Execute SQL queries on a SQLite database and return results. | +| | `query_mongodb` | Perform queries or operations on a MongoDB collection. | +| Text Processing | `summarization` | Summarize a piece of text using a large language model to highlight its main points. | +| Web Search | `web_search` | Perform a web search using a specified search engine (currently supports Google and Bing). | +| | `load_web` | Load and parse the web page of the specificed url (currently only supports HTML). | +| | `digest_webpage` | Digest the content of a already loaded web page (currently only supports HTML). | +| File | `create_file` | Create a new file at a specified path, optionally with initial content. | +| | `delete_file` | Delete a file specified by a file path. | +| | `move_file` | Move or rename a file from one path to another. | +| | `create_directory` | Create a new directory at a specified path. | +| | `delete_directory` | Delete a directory and all its contents. | +| | `move_directory` | Move or rename a directory from one path to another. | +| | `read_text_file` | Read and return the content of a text file. | +| | `write_text_file` | Write text content to a file at a specified path. | +| | `read_json_file` | Read and parse the content of a JSON file. | +| | `write_json_file` | Serialize a Python object to JSON and write to a file. | | *More services coming soon* | | More service functions are in development and will be added to AgentScope to further enhance its capabilities. | About each service function, you can find detailed information in the diff --git a/docs/sphinx_doc/en/source/tutorial/302-contribute.md b/docs/sphinx_doc/en/source/tutorial/302-contribute.md index e4f8b1bbe..be7a7231a 100644 --- a/docs/sphinx_doc/en/source/tutorial/302-contribute.md +++ b/docs/sphinx_doc/en/source/tutorial/302-contribute.md @@ -21,8 +21,8 @@ Did you find a bug or have a feature request? Please first check the issue track To work on an issue or a new feature, start by forking the AgentScope repository and then cloning your fork locally. ```bash -git clone https://github.com/your-username/AgentScope.git -cd AgentScope +git clone https://github.com/your-username/agentscope.git +cd agentscope ``` ### Create a New Branch diff --git a/docs/sphinx_doc/zh_CN/source/agentscope.models.rst b/docs/sphinx_doc/zh_CN/source/agentscope.models.rst index a61cbdfaa..3ce904d54 100644 --- a/docs/sphinx_doc/zh_CN/source/agentscope.models.rst +++ b/docs/sphinx_doc/zh_CN/source/agentscope.models.rst @@ -17,6 +17,14 @@ model module :undoc-members: :show-inheritance: +dashscope\_model module +--------------------------------------- + +.. automodule:: agentscope.models.dashscope_model + :members: + :undoc-members: + :show-inheritance: + openai\_model module --------------------------------------- @@ -25,6 +33,22 @@ openai\_model module :undoc-members: :show-inheritance: +ollama\_model module +--------------------------------------- + +.. automodule:: agentscope.models.ollama_model + :members: + :undoc-members: + :show-inheritance: + +gemini\_model module +--------------------------------------- + +.. automodule:: agentscope.models.gemini_model + :members: + :undoc-members: + :show-inheritance: + post\_model module ------------------------------------- diff --git a/docs/sphinx_doc/zh_CN/source/agentscope.service.web_search.rst b/docs/sphinx_doc/zh_CN/source/agentscope.service.web_search.rst index 895ab915c..d2ef72a9a 100644 --- a/docs/sphinx_doc/zh_CN/source/agentscope.service.web_search.rst +++ b/docs/sphinx_doc/zh_CN/source/agentscope.service.web_search.rst @@ -9,3 +9,10 @@ search module :undoc-members: :show-inheritance: +web\_digest module +--------------------------------------------- + +.. automodule:: agentscope.service.web_search.web_digest + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/sphinx_doc/zh_CN/source/tutorial/102-installation.md b/docs/sphinx_doc/zh_CN/source/tutorial/102-installation.md index 3c5ee0a4c..fbfc7f355 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/102-installation.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/102-installation.md @@ -44,7 +44,7 @@ source agentscope/bin/activate # 在Windows上使用`agentscope\Scripts\activat ```bash # 从GitHub上拉取AgentScope的源代码 git clone https://github.com/modelscope/agentscope.git -cd AgentScope +cd agentscope # 针对本地化的multi-agent应用 pip install -e . diff --git a/docs/sphinx_doc/zh_CN/source/tutorial/104-usecase.md b/docs/sphinx_doc/zh_CN/source/tutorial/104-usecase.md index cb746fa6f..eb2db904e 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/104-usecase.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/104-usecase.md @@ -14,7 +14,7 @@ 首先,确保您已经正确安装和配置好AgentScope。除此之外,本节内容会涉及到`Model API`, `Agent`, `Msg`和 `Pipeline`这几个概念(详情可以参考[关于AgentScope](101-agentscope))。以下是本节教程内容概览。 -**提示**:本教程中的所有配置和代码文件均可以在`examples/werewolf`中找到。 +**提示**:本教程中的所有配置和代码文件均可以在`examples/game_werewolf`中找到。 ### 第一步: 准备模型API和设定模型配置 @@ -72,7 +72,7 @@ AgentScope提供了几种开箱即用的agent实现,作为一个agent样例池 在这个配置中,Player1被指定为一个DictDialogAgent。参数包括一个系统提示(sys_prompt),它可以指导agent的行为;一个模型配置名(model_config_name),它决定了模型配置的名称;以及一个标志(use_memory),指示agent是否应该记住过去的互动。 -对于其他玩家,大家可以根据他们的角色进行定制。每个角色可能有不同的提示、模型或记忆设置。你可以参考位于AgentScope示例目录下的`examples/werewolf/configs/agent_configs.json`文件。 +对于其他玩家,大家可以根据他们的角色进行定制。每个角色可能有不同的提示、模型或记忆设置。你可以参考位于AgentScope示例目录下的`examples/game_werewolf/configs/agent_configs.json`文件。 ### 第三步:初始化AgentScope和Agents @@ -153,7 +153,7 @@ for i in range(1, MAX_GAME_ROUND + 1): 讨论结束后,根据少数服从多数,狼人进行投票选出他们的目标。然后,投票的结果将广播给所有狼人。 -注意:具体的提示和实用函数可以在`examples/werewolf`中找到。 +注意:具体的提示和实用函数可以在`examples/game_werewolf`中找到。 ```python # werewolves vote diff --git a/docs/sphinx_doc/zh_CN/source/tutorial/201-agent.md b/docs/sphinx_doc/zh_CN/source/tutorial/201-agent.md index 7ac90a07f..59bf0d6fa 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/201-agent.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/201-agent.md @@ -63,12 +63,15 @@ class AgentBase(Operator): 以下是一个总结了 AgentPool 中一些关键agent的功能的表格: -| Agent 种类 | 描述 | Typical Use Cases | -|--------------|--------------------------------------------------|-------------------| -| `AgentBase` | 作为所有agent的超类,提供了必要的属性和方法。 | 构建任何自定义agent的基础。 | -| `DialogAgent` | 通过理解上下文和生成连贯的响应来管理对话。 | 客户服务机器人,虚拟助手。 | -| `UserAgent` | 与用户互动以收集输入,生成可能包括URL或基于所需键的额外具体信息的消息。 | 为agent收集用户输入 | -| *更多agent* | AgentScope 正在不断扩大agent池,加入更多专门化的agent,以适应多样化的应用。 | | +| Agent 种类 | 描述 | Typical Use Cases | +| ------------------ | --------------------------------------------------------------------------- | --------------------------- | +| `AgentBase` | 作为所有agent的超类,提供了必要的属性和方法。 | 构建任何自定义agent的基础。 | +| `DialogAgent` | 通过理解上下文和生成连贯的响应来管理对话。 | 客户服务机器人,虚拟助手。 | +| `DictDialogAgent` | 通过理解上下文和生成连贯的响应来管理对话,返回的消息为 Json 格式。 | 客户服务机器人,虚拟助手。 | +| `UserAgent` | 与用户互动以收集输入,生成可能包括URL或基于所需键的额外具体信息的消息。 | 为agent收集用户输入 | +| `TextToImageAgent` | 将用户输入的文本转化为图片 | 提供文生图功能 | +| `ReActAgent` | 实现了 ReAct 算法的 Agent,能够自动调用工具处理较为复杂的任务。 | 借助工具解决复杂任务 | +| *更多agent* | AgentScope 正在不断扩大agent池,加入更多专门化的agent,以适应多样化的应用。 | | ## 从Agent池中定制Agent diff --git a/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md b/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md index 78ddbcb9b..a70672d86 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md @@ -9,25 +9,27 @@ 下面的表格按照类型概述了各种Service函数。以下函数可以通过`agentscope.service.{函数名}`进行调用。 -| Service场景 | Service函数名称 | 描述 | -|------------|-----------------------| ------------------------------------------------------------ | -| 代码 | `execute_python_code` | 执行一段 Python 代码,可选择在 Docker
容器内部执行。 | -| 检索 | `retrieve_from_list` | 根据给定的标准从列表中检索特定项目。 | -| SQL查询 | `query_mysql` | 在 MySQL 数据库上执行 SQL 查询并返回结果。 | -| | `query_sqlite` | 在 SQLite 数据库上执行 SQL 查询并返回结果。 | -| | `query_mongodb` | 对 MongoDB 集合执行查询或操作。 | -| 文本处理 | `summarization` | 使用大型语言模型总结一段文字以突出其主要要点。 | -| 网络搜索 | `web_search` | 使用指定的搜索引擎(当前支持 Google 和 Bing)执行网络搜索。 | -| 文件处理 | `create_file` | 在指定路径创建一个新文件,并可选择添加初始内容。 | -| | `delete_file` | 删除由文件路径指定的文件。 | -| | `move_file` | 将文件从一个路径移动或重命名到另一个路径。 | -| | `create_directory` | 在指定路径创建一个新的目录。 | -| | `delete_directory` | 删除一个目录及其所有内容。 | -| | `move_directory` | 将目录从一个路径移动或重命名到另一个路径。 | -| | `read_text_file` | 读取并返回文本文件的内容。 | -| | `write_text_file` | 向指定路径的文件写入文本内容。 | -| | `read_json_file` | 读取并解析 JSON 文件的内容。 | -| | `write_json_file` | 将 Python 对象序列化为 JSON 并写入到文件。 | +| Service场景 | Service函数名称 | 描述 | +| ------------------ | --------------------- | ---------------------------------------------------------------- | +| 代码 | `execute_python_code` | 执行一段 Python 代码,可选择在 Docker
容器内部执行。 | +| 检索 | `retrieve_from_list` | 根据给定的标准从列表中检索特定项目。 | +| SQL查询 | `query_mysql` | 在 MySQL 数据库上执行 SQL 查询并返回结果。 | +| | `query_sqlite` | 在 SQLite 数据库上执行 SQL 查询并返回结果。 | +| | `query_mongodb` | 对 MongoDB 集合执行查询或操作。 | +| 文本处理 | `summarization` | 使用大型语言模型总结一段文字以突出其主要要点。 | +| 网络搜索 | `web_search` | 使用指定的搜索引擎(当前支持 Google 和 Bing)执行网络搜索。 | +| | `load_web` | 爬取并解析指定的网页链接 (目前仅支持爬取 HTML 页面) | +| | `digest_webpage` | 对已经爬取好的网页生成摘要信息(目前仅支持 HTML 页面) | +| 文件处理 | `create_file` | 在指定路径创建一个新文件,并可选择添加初始内容。 | +| | `delete_file` | 删除由文件路径指定的文件。 | +| | `move_file` | 将文件从一个路径移动或重命名到另一个路径。 | +| | `create_directory` | 在指定路径创建一个新的目录。 | +| | `delete_directory` | 删除一个目录及其所有内容。 | +| | `move_directory` | 将目录从一个路径移动或重命名到另一个路径。 | +| | `read_text_file` | 读取并返回文本文件的内容。 | +| | `write_text_file` | 向指定路径的文件写入文本内容。 | +| | `read_json_file` | 读取并解析 JSON 文件的内容。 | +| | `write_json_file` | 将 Python 对象序列化为 JSON 并写入到文件。 | | *更多服务即将推出* | | 正在开发更多服务功能,并将添加到 AgentScope 以进一步增强其能力。 | 关于详细的参数、预期输入格式、返回类型,请参阅[API文档](https://modelscope.github.io/agentscope/)。 diff --git a/docs/sphinx_doc/zh_CN/source/tutorial/302-contribute.md b/docs/sphinx_doc/zh_CN/source/tutorial/302-contribute.md index f719ad4e6..7c9f7d64c 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/302-contribute.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/302-contribute.md @@ -21,8 +21,8 @@ 要处理一个问题或新功能,首先要Fork AgentScope仓库,然后将你的Fork克隆到本地。 ```bash -git clone https://github.com/your-username/AgentScope.git -cd AgentScope +git clone https://github.com/your-username/agentscope.git +cd agentscope ``` ### 创建一个新分支 diff --git a/setup.py b/setup.py index 41bd33459..10b1dfc8d 100644 --- a/setup.py +++ b/setup.py @@ -93,6 +93,7 @@ keywords=["deep-learning", "multi agents", "agents"], package_dir={"": "src"}, packages=setuptools.find_packages("src"), + package_data={"agentscope.web": ["static/**/*"]}, install_requires=minimal_requires, extras_require={ "distribute": distribute_requires, diff --git a/src/agentscope/agents/text_to_image_agent.py b/src/agentscope/agents/text_to_image_agent.py index 9b706382f..f31fb55df 100644 --- a/src/agentscope/agents/text_to_image_agent.py +++ b/src/agentscope/agents/text_to_image_agent.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""A agent that convert text to image.""" +"""An agent that convert text to image.""" from typing import Optional diff --git a/src/agentscope/models/dashscope_model.py b/src/agentscope/models/dashscope_model.py index e150ae503..07d26cdc5 100644 --- a/src/agentscope/models/dashscope_model.py +++ b/src/agentscope/models/dashscope_model.py @@ -311,8 +311,8 @@ def advanced_format( { "role": "system", "content": ( - "system: You're a helpful assistant\n", - "Bob: Hi, how can I help you?\n", + "system: You're a helpful assistant\\n", + "Bob: Hi, how can I help you?\\n", "user: What's the date today?" ) } diff --git a/src/agentscope/models/post_model.py b/src/agentscope/models/post_model.py index a0621d5fd..72c3ab355 100644 --- a/src/agentscope/models/post_model.py +++ b/src/agentscope/models/post_model.py @@ -211,7 +211,9 @@ def format(self, *args: Union[Msg, Sequence[Msg]]) -> Union[List[dict]]: class PostAPIDALLEWrapper(PostAPIModelWrapperBase): """A post api model wrapper compatible with openai dalle""" - model_type: str = "post_api_dalle" + model_type: str = "post_api_dall_e" + + deprecated_model_type: str = "post_api_dalle" def _parse_response(self, response: dict) -> ModelResponse: urls = [img["url"] for img in response["data"]["response"]["data"]] diff --git a/src/agentscope/service/web_search/web_digest.py b/src/agentscope/service/web_search/web_digest.py index 6433822ed..da0f76622 100644 --- a/src/agentscope/service/web_search/web_digest.py +++ b/src/agentscope/service/web_search/web_digest.py @@ -45,6 +45,7 @@ def load_web( timeout: int = 5, ) -> ServiceResponse: """Function for parsing and digesting the web page. + Args: url (str): the url of the web page keep_raw (bool): @@ -62,22 +63,29 @@ def load_web( key timeout (int): timeout parameter for requests. - Returns: `ServiceResponse`: If successful, `ServiceResponse` object is returned with `content` field is a dict, where keys are subset of: + "raw": exists if `keep_raw` is True, store raw HTML content`; + "self_define_func": exists if `self_parse_func` is provided, - store the return of self_define_func; + store the return of self_define_func; + "html_to_text": exists if `html_selected_tags` is provided - and not empty; + and not empty; + "json": exists if url links to a json webpage, then it is - parsed as json. + parsed as json. + For example, `ServiceResponse.content` field is - { - "raw": xxxxx, - "selected_tags_text": xxxxx - } + + .. code-block:: python + + { + "raw": xxxxx, + "selected_tags_text": xxxxx + } """ header = { "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", @@ -148,12 +156,14 @@ def parse_html_to_text( ) -> str: """ Parse the obtained HTML file. + Args: html_text (str): HTML source code html_selected_tags (Optional[Sequence[str]]): the text in elements of `html_selected_tags` will be extracted and returned. + Returns: `ServiceResponse`: If successful, `ServiceResponse` object is returned with `content` field is processed text content of the selected tags,