Skip to content

Commit

Permalink
reorganize to align with the template
Browse files Browse the repository at this point in the history
  • Loading branch information
PengHongyiNTU committed May 14, 2024
1 parent 7972698 commit cccecb2
Showing 1 changed file with 58 additions and 23 deletions.
81 changes: 58 additions & 23 deletions examples/customized_services/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"---"
]
},
Expand All @@ -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",
Expand Down Expand Up @@ -429,6 +443,13 @@
"import requests"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Text to Image"
]
},
{
"cell_type": "code",
"execution_count": 8,
Expand Down Expand Up @@ -478,6 +499,13 @@
" return ServiceResponse(ServiceExecStatus.FAILURE, err_msg)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Image to text"
]
},
{
"cell_type": "code",
"execution_count": 9,
Expand Down Expand Up @@ -528,6 +556,13 @@
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Text to audio"
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand Down

0 comments on commit cccecb2

Please sign in to comment.