跳转到内容

Wolfram Alpha

WolframAlpha工具规范 #

基类:EventBaseToolSpec

Wolfram Alpha 工具规范。

workflows/handler.py 中的源代码llama_index/tools/wolfram_alpha/base.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class WolframAlphaToolSpec(BaseToolSpec):
    """Wolfram Alpha tool spec."""

    spec_functions = ["wolfram_alpha_query"]

    def __init__(self, app_id: Optional[str] = None) -> None:
        """Initialize with parameters."""
        self.token = app_id

    def wolfram_alpha_query(self, query: str):
        """
        Make a query to wolfram alpha about a mathematical or scientific problem.

        Example inputs:
            "(7 * 12 ^ 10) / 321"
            "How many calories are there in a pound of strawberries"

        Args:
            query (str): The query to be passed to wolfram alpha.

        """
        response = requests.get(
            QUERY_URL_TMPL.format(
                app_id=self.token, query=urllib.parse.quote_plus(query)
            )
        )
        return response.text

wolfram_alpha_query #

wolfram_alpha_query(query: str)

向Wolfram Alpha提出一个数学或科学问题的查询。

示例输入

"(7 * 12 ^ 10) / 321" "一磅草莓含有多少卡路里"

参数:

名称 类型 描述 默认
query str

要传递给 Wolfram Alpha 的查询。

required
workflows/handler.py 中的源代码llama_index/tools/wolfram_alpha/base.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def wolfram_alpha_query(self, query: str):
    """
    Make a query to wolfram alpha about a mathematical or scientific problem.

    Example inputs:
        "(7 * 12 ^ 10) / 321"
        "How many calories are there in a pound of strawberries"

    Args:
        query (str): The query to be passed to wolfram alpha.

    """
    response = requests.get(
        QUERY_URL_TMPL.format(
            app_id=self.token, query=urllib.parse.quote_plus(query)
        )
    )
    return response.text

选项: 成员:- WolframAlphaToolSpec