分数计算器
对两个分数进行加、减、乘、除运算。
基础 URL:https://happytails.ai · 公共 API 尚未连接
处理方式
约分后的分数是精确值。带分数表示相同的值,小数为近似值。
通过 API 提交的输入数据会在服务器上处理。
请求参数
请发送 JSON 对象。系统会拒绝未知属性。省略的选项使用下方的默认值。数字和布尔值应作为 JSON 值输入,无需加引号。
无需输入文本。请使用下方的设置。
此端点不接受 files 数组。
选项
options.anumber分子 A
options.bnumber分母 A
options.opstring运算
options.cnumber分子 B
options.dnumber分母 B
成功响应
HTTP 200 响应中包含 tool 和 result。文本在 result.text 中,解析后的 JSON 也可能出现在 result.data 中。生成的文件位于 result.files 中,包含 name、mime、bytes 和 base64。保存前请先对字节进行解码。如果操作返回其他类型的结果,文件数组为空或文本值为 null 都是有效的。
完整输出架构
{
"type": "object",
"required": [
"tool",
"result"
],
"properties": {
"tool": {
"type": "string"
},
"result": {
"type": "object",
"required": [
"text",
"files"
],
"properties": {
"text": {
"type": [
"string",
"null"
]
},
"data": {
"description": "Parsed JSON when the textual result is JSON."
},
"name": {
"type": "string"
},
"mime": {
"type": "string"
},
"files": {
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"mime",
"bytes",
"base64"
],
"properties": {
"name": {
"type": "string"
},
"mime": {
"type": "string"
},
"bytes": {
"type": "integer"
},
"base64": {
"type": "string",
"contentEncoding": "base64"
}
}
}
}
}
}
}
}限制和错误
此端点会执行下列限制。运行说明中列出的格式、页数、时长和模型限制也同样适用。浏览器界面的限制可能与 API 不同。
request_bytes- 8388608
input_characters- 1000000
files_bytes- 5242880
max_files- 0
timeout_seconds- 12
无效请求会返回一个含有 code 和 message 的 error 对象。请参阅HTTP 状态码、重试、超时和并发请求。请求以同步方式处理,结果随同一响应返回。
完整请求架构
展开 JSON 架构
{
"type": "object",
"additionalProperties": false,
"properties": {
"input": {
"type": "string",
"maxLength": 1000000,
"default": "",
"description": "Plain text input. File tools use files instead unless otherwise documented."
},
"options": {
"type": "object",
"additionalProperties": false,
"properties": {
"a": {
"type": "number",
"description": "Numerator A",
"default": 1.0,
"minimum": -1000000,
"maximum": 1000000,
"multipleOf": 1
},
"b": {
"type": "number",
"description": "Denominator A",
"default": 2.0,
"minimum": -1000000,
"maximum": 1000000,
"multipleOf": 1
},
"op": {
"type": "string",
"description": "Operation",
"default": "+",
"enum": [
"+",
"-",
"×",
"÷"
]
},
"c": {
"type": "number",
"description": "Numerator B",
"default": 1.0,
"minimum": -1000000,
"maximum": 1000000,
"multipleOf": 1
},
"d": {
"type": "number",
"description": "Denominator B",
"default": 3.0,
"minimum": -1000000,
"maximum": 1000000,
"multipleOf": 1
}
}
}
}
}如需自动操作浏览器,请通过统一的 WebMCP 指南 查看浏览器实际提供哪些工具。
请求示例
curl https://happytails.ai/api/v1/tools/fractions/run \
-H "Content-Type: application/json" \
--data '{"options": {"a": 1.0, "b": 2.0, "op": "+", "c": 1.0, "d": 3.0}}'const payload = {
"options": {
"a": 1.0,
"b": 2.0,
"op": "+",
"c": 1.0,
"d": 3.0
}
};
const response = await fetch(
"https://happytails.ai/api/v1/tools/fractions/run",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
}
);
const data = await response.json();
if (!response.ok) throw new Error(data.error.message);
console.log(data.result);import json
from urllib.request import Request, urlopen
payload = json.loads('{"options": {"a": 1.0, "b": 2.0, "op": "+", "c": 1.0, "d": 3.0}}')
request = Request(
"https://happytails.ai/api/v1/tools/fractions/run",
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
)
with urlopen(request, timeout=200) as response:
result = json.load(response)
print(result){
"options": {
"a": 1.0,
"b": 2.0,
"op": "+",
"c": 1.0,
"d": 3.0
}
}请将 API 的源地址和输入值替换为适合你的应用程序的值。
200 OK · 响应结构
{
"tool": "fractions",
"result": {
"text": null,
"files": []
}
}响应结构示例。实际的文本、文件名、MIME 类型和字节数取决于结果。请参阅完整的输出架构。
400 · 无效请求
{
"error": {
"code": "INVALID_INPUT",
"message": "Unknown request property. See the tool input schema."
}
}