默认值
| 调用 | 截止时间截止时间 | 原因 |
|---|---|---|
| 大部分电话 | 60 秒 | 迄今尚未收到的答复将不来。 |
| models.turn() | 300 秒 | 转弯可以思考很久 才能找到答案 |
| assistant.generate() | 无 | 一代人可以花几分钟时间,见下文。 |
| tools.convert(), tools.fetch() | 无 | 理由是一样的 |
| 串流电话 | 无 | 连接是故意开放的。 |
为什么一代人没有最后期限
工作之所以不停止,是因为您停止了听话:它结束了,电话仍然在账单上。 因此客户端的最后期限会花费您打电话的费用,而不会归还任何信息。 使用中止信号把它打中,而由您控制。
设置您自己的
// For the whole client
const api = new IaGenify({ apiKey, timeout: 15_000 });
// For one call
await api.models.turn({ model, messages, signal: AbortSignal.timeout(30_000) });# For the whole client, in seconds
api = IaGenify(api_key=api_key, timeout=15)
# For one call
api.models.turn(model=model, messages=messages, timeout=30)中止中中止
每一个电话都需 signal。您要求的堕胎会按原样通过,不会被重新包装为超时,这样除了客户放弃外,您还可以告诉自己取消。
const controller = new AbortController();
const running = agent.run({
message: "Audit the whole workspace.",
onEvent: console.log,
signal: controller.signal,
});
setTimeout(() => controller.abort(new Error("user cancelled")), 10_000);
try {
await running;
} catch (err) {
if (controller.signal.aborted) console.log("cancelled by us");
else if (err.code === "timeout") console.log("the client gave up");
}import threading
from iagenify import RequestTimeout
# Python has no AbortSignal: stop the agent from another thread
timer = threading.Timer(10, agent.stop)
timer.start()
try:
result = agent.run(message="Audit the whole workspace.", on_event=print)
if result["stopReason"] == "stopped":
print("cancelled by us")
except RequestTimeout:
print("the client gave up")
finally:
timer.cancel()你将看到两个失败
| 代码代码代码 | 状态状态状态状态状态状态状态 | 含义 |
|---|---|---|
| 超时超时 | 408 | 截止日期前没有答复。 |
| 无法到达 | 503 | 请求从未到过那里: 错误的基调Url, 没有网络, 什么都没有听。 |
unreachable 几乎总是意味着 baseUrl 不是您指的是的。 读 api.baseUrl 并且比较它, https://api.iagenify.com.