From cccecb23f56591d859403f86ff0360a5cb4dda1c Mon Sep 17 00:00:00 2001 From: HONGYI001 Date: Tue, 14 May 2024 21:13:06 +0800 Subject: [PATCH] reorganize to align with the template --- examples/customized_services/main.ipynb | 81 ++++++++++++++++++------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/examples/customized_services/main.ipynb b/examples/customized_services/main.ipynb index 62c5d7412..5d8e697df 100644 --- a/examples/customized_services/main.ipynb +++ b/examples/customized_services/main.ipynb @@ -4,59 +4,69 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Customized Services\n", - "----\n" + "# Customized Services\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "In `agentscope`, a \"service\" is a set of multi-functional utility tools that can be used to enhance the capabilities of agents. `agentscope` has provided a variety of services, including executing Python code, web searching, file operations, and so on. For more details, we refer the reader to agentscope/tutorials/services. we refere the reader to [agentscope/tutorials/services](https://modelscope.github.io/agentscope/en/tutorial/204-service.html)" + "This example will show how to intergrate the following external functions as customized services in **Agentscope**:\n", + "- langchain tools \n", + "- dashscope text-to-image\n", + "- dashscope image-to-text\n", + "- dashscope text-to-audio\n", + "\n", + "Meanwhile, we are consistently working on bringing more and more services into **Agentscope**. The external services introduced in these examples will soon be merged into our library and have official support!\n", + "\n", + "_Current progress_: Langchain tools 🚧, dashscope_text_to_image 🚧, dashscope_image_to_text 🚧, dashscope_text_to_audio 🚧...\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "With `agentscope`, you can also implement customized services with no hassle. In this example, we demonstrate how to wrap the following external functions as services in `agentscope`:\n", - "- langchain tools\n", - "- dashscope text-to-image\n", - "- dashscope image-to-text\n", - "- dashscope text-to-audio" + "## Tested Models" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "**Note**: The example is tested with the following models. \n", - "For other models, you may need to adjust the prompt.\n", + "These models are tested in this example. For other models, some modifications may be needed.\n", "- gpt-4\n", "- gpt-3.5-turbo" ] }, { "cell_type": "markdown", - "metadata": { - "notebookRunGroups": { - "groupValue": "" - } - }, + "metadata": {}, "source": [ - "---" + "## Prerequisites\n", + "- Follow [READMD.md](https://github.com/modelscope/agentscope) to install AgentScope. \n", + "- Run folling code to install other required library includes [LangChain](https://python.langchain.com/v0.1/docs/get_started/quickstart/) and [Dashscope](https://dashscope.aliyun.com/).```!pip install langchain dashscope pyowm```\n", + "- Prepare a model configuration. AgentScope supports both local deployed model services (CPU or GPU) and third-party services. More details and example model configurations please refer to our [tutorial](https://modelscope.github.io/agentscope/en/tutorial/203-model.html).\n", + "- Prepare API keys for `OpenWeatherMao` and `Dashscope` " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Table of Contents \n", + "- [Background](##Background)\n", + "- [Langchain Tools](##Langchain-tools)\n", + "- [Dashscope](#dashscope)\n", + " - [Text2Img](###Text-to-Image)\n", + " - [Img2Text](###Image-to-Text)\n", + " - [Text2Audio](###Text-to-Audio)\n", + "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Prerequisites\n", - "To get started, run the following code directly in your Jupyter notebook to install [LangChain](https://python.langchain.com/v0.1/docs/get_started/quickstart/) and [DashScope](https://dashscope.aliyun.com/).\n", - "\n", - "```python\n", - "!pip install langchain dashscope pyowm\n", - "```\n", "---" ] }, @@ -65,7 +75,11 @@ "metadata": {}, "source": [ "## Background\n", - "Implementing a customized service is as simple as writing a custom function, as shown below:\n", + "\n", + "In **Agentscope**, a \"service\" is a set of multi-functional utility tools that can be used to enhance the capabilities of agents. **Agentscope** has provided a variety of services, including executing Python code, web searching, file operations, and so on. For more details, we refer the reader to agentscope/tutorials/services. we refere the reader to [agentscope/tutorials/services](https://modelscope.github.io/agentscope/en/tutorial/204-service.html.\n", + "\n", + "\n", + "For tools that are not covered in **Agentscope**, implementing a customized service is as simple as writing a custom function, as shown below:\n", "```python\n", "from agentscope.service.service_response import ServiceResponse, ServiceExecStatus\n", "def your_customized_services(argument_1, argument_2) -> ServiceResponse\n", @@ -429,6 +443,13 @@ "import requests" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Text to Image" + ] + }, { "cell_type": "code", "execution_count": 8, @@ -478,6 +499,13 @@ " return ServiceResponse(ServiceExecStatus.FAILURE, err_msg)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Image to text" + ] + }, { "cell_type": "code", "execution_count": 9, @@ -528,6 +556,13 @@ " " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Text to audio" + ] + }, { "cell_type": "code", "execution_count": 10,