From 46767111c46a509bc19b5978375b9c1d60ddd3d2 Mon Sep 17 00:00:00 2001 From: zyzhang1130 <36942574+zyzhang1130@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:08:11 +0800 Subject: [PATCH] updated the doc --- .../en/source/tutorial/204-service.md | 6 +-- .../zh_CN/source/tutorial/204-service.md | 6 +-- .../service/reasoning/wolfram_alpha.py | 47 +++++++++++-------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/docs/sphinx_doc/en/source/tutorial/204-service.md b/docs/sphinx_doc/en/source/tutorial/204-service.md index 1c3744955..71ecd902d 100644 --- a/docs/sphinx_doc/en/source/tutorial/204-service.md +++ b/docs/sphinx_doc/en/source/tutorial/204-service.md @@ -49,10 +49,10 @@ The following table outlines the various Service functions by type. These functi | | `openai_image_to_text` | Convert text to image using OpenAI API | | `openai_text_to_audio` | Convert text to audio using OpenAI API | | `openai_audio_to_text` | Convert audio to text using OpenAI API -| Reasoning | `wolfram_alpha_short_answers_query` | Query the Wolfram Alpha Short Answers API and return the answer as a string. | +| Reasoning | `wolfram_alpha_short_answers_query` | Query the Wolfram Alpha Short Answers API and return a brief answer in text. | | | `wolfram_alpha_simple_query` | Query the Wolfram Alpha Simple API and return the answer as a PNG image. | -| | `wolfram_alpha_show_steps_query` | Query the Wolfram Alpha Show Steps API and return the step-by-step solution as a string. | -| | `wolfram_alpha_llm_query` | Query the Wolfram Alpha LLM API and return the answer from the LLM as a string. | +| | `wolfram_alpha_show_steps_query` | Query the Wolfram Alpha Show Steps API and return the step-by-step solution in text. | +| | `wolfram_alpha_llm_query` | Query the Wolfram Alpha LLM API and return the answer from the LLM in text. | | *More services coming soon* | | More service functions are in development and will be added to AgentScope to further enhance its capabilities. | 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 8b8561b22..d270f3ec2 100644 --- a/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md +++ b/docs/sphinx_doc/zh_CN/source/tutorial/204-service.md @@ -46,10 +46,10 @@ | | `openai_image_to_text` | 使用 OpenAI API 根据图片生成文字。 | | `openai_text_to_audio` | 使用 OpenAI API 根据文本生成音频。 | | `openai_audio_to_text` | 使用OpenAI API将音频转换为文本。 -| 推理 | wolfram_alpha_short_answers_query | 查询 Wolfram Alpha Short Answers API, 并以字符串形式返回答案。 | +| 推理 | wolfram_alpha_short_answers_query | 查询 Wolfram Alpha Short Answers API, 并以文本形式返回简短的答案。 | | | wolfram_alpha_simple_query | 查询 Wolfram Alpha Simple API,并以PNG图片形式返回答案。。 | -| | wolfram_alpha_show_steps_query | 查询 Wolfram Alpha Show Steps API,并返回逐步解决方案作为字符串。 | -| | wolfram_alpha_llm_query | 查询 Wolfram Alpha LLM API,并将LLM返回的答案作为字符串返回。 | +| | wolfram_alpha_show_steps_query | 查询 Wolfram Alpha Show Steps API,并以文本形式返回返回逐步答案。 | +| | wolfram_alpha_llm_query | 查询 Wolfram Alpha LLM API,并将LLM返回的答案作为文本形式返回。 | | *更多服务即将推出* | | 正在开发更多服务功能,并将添加到 AgentScope 以进一步增强其能力。 | 关于详细的参数、预期输入格式、返回类型,请参阅[API文档](https://modelscope.github.io/agentscope/)。 diff --git a/src/agentscope/service/reasoning/wolfram_alpha.py b/src/agentscope/service/reasoning/wolfram_alpha.py index 5b4d2f9b8..09bade7c6 100644 --- a/src/agentscope/service/reasoning/wolfram_alpha.py +++ b/src/agentscope/service/reasoning/wolfram_alpha.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """Query Wolfram Alpha API""" import os -from typing import Any, Dict # Corrected import order -import requests # Corrected import order -from loguru import logger # Corrected import order +from typing import Any, Dict +import requests +from loguru import logger from agentscope.service.service_response import ( ServiceResponse, ServiceExecStatus, @@ -16,11 +16,12 @@ def wolfram_alpha_short_answers_query( ) -> ServiceResponse: """ Query the Wolfram Alpha Short Answers API. The Short Answers API returns - a single plain text result directly from Wolfram|Alpha. In general, this - text is taken directly from the Result pod of Wolfram|Alpha output. This - API type is designed to deliver brief answers in the most basic - format possible. Suitable for queries such as simple knowledge/facts - retrieval. See + a single plain text result directly from Wolfram|Alpha. + + In general, this text is taken directly from the Result pod of + Wolfram|Alpha output. This API type is designed to deliver brief + answers in the most basic format possible. Suitable for queries + such as simple knowledge/facts retrieval. See https://products.wolframalpha.com/short-answers-api/documentation for more details. @@ -79,6 +80,7 @@ def wolfram_alpha_simple_query( """ Query the Wolfram Alpha Simple API. The Simple API generates full Wolfram|Alpha output in a universally viewable image format. + Suitable for queries such as knowledge/facts retrieval. See https://products.wolframalpha.com/simple-api/documentation for more details. @@ -152,12 +154,14 @@ def wolfram_alpha_show_steps_query( query: str, ) -> ServiceResponse: """ - Query the Wolfram Alpha Show Steps API. An extension of the - Full Results API, the Show Steps API gives direct access to - Wolfram|Alpha's full for queries in a variety of mathematical - and scientific subjects. These explanations of computed answers - are designed to provide clarity and understanding to the - end user and are especially useful in educational and + Query the Wolfram Alpha Show Steps API, gives step-by-step solution + in text. + + An extension of the Full Results API, the Show Steps API gives + direct access to Wolfram|Alpha's full for queries in a variety + of mathematical and scientific subjects. These explanations of + computed answers are designed to provide clarity and understanding + to the end user and are especially useful in educational and training applications. see https://products.wolframalpha.com/show-steps-api/documentation for more details. @@ -255,12 +259,15 @@ def wolfram_alpha_llm_query( query: str, ) -> ServiceResponse: """ - Query the Wolfram Alpha LLM API. The LLM API is built for - use specifically with large language models and chat products. - Although the majority of data available through the - Wolfram|Alpha website is also available through this API, - certain subjects may be restricted by default. see - https://products.wolframalpha.com/llm-api/documentation for more details. + Query the Wolfram Alpha LLM API and return solution as text. + + The LLM API is built for use specifically with large language + models and chat products. Although the majority of data + available through the Wolfram|Alpha website is also available + through this API, certain subjects may be restricted by default. + see + https://products.wolframalpha.com/llm-api/documentation + for more details. Args: api_key (`str`):