分數計算機
對兩個分數進行加、減、乘、除運算。
基礎 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."
}
}