参数
idstring必填届会代 届会代 , assistant.id 或 (列表).
返回值
A 音 A 助理会期,在种类上与什么相同 create() 给了你:相同的配置,相同的ID, 和后面的谈话。
// First run
const assistant = await api.models.create({ model: "gemini-3.5-flash" });
await db.save(userId, assistant.id);
await assistant.generate({ inputs: [{ type: "text", content: "My name is Zayd." }] });
// A week later, a different process
const again = await api.models.get(await db.load(userId));
await again.generate({ inputs: [{ type: "text", content: "What is my name?" }] });
// It knows — the conversation came back with the session.# First run
assistant = api.models.create(model="gemini-3.5-flash")
db.save(user_id, assistant.id)
assistant.generate(inputs=[{"type": "text", "content": "My name is Zayd."}])
# A week later, a different process
again = api.models.get(db.load(user_id))
again.generate(inputs=[{"type": "text", "content": "What is my name?"}])
# It knows — the conversation came back with the session.身份证是你唯一要保存的东西
其它一切——模型、设置、计划、历史——都在服务器上,将会议所属的代号放在会话旁边,不需要再坚持了。
错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| session_not_found | 404 | 这笔账户的任何一届会议都未包含这一ID,包括一个错误的ID。 |
It throws rather than returning null, so a missing session is an exception to catch, not a value to test.
import { IaGenifyError } from "iagenify";
async function resume(api, id, model) {
try {
return await api.models.get(id);
} catch (err) {
if (err instanceof IaGenifyError && err.status === 404) {
// Deleted, or belonging to another account. Start a fresh one.
return api.models.create({ model });
}
throw err;
}
}from iagenify import IaGenifyError
def resume(api, session_id, model):
try:
return api.models.get(session_id)
except IaGenifyError as error:
if error.status == 404:
# Deleted, or belonging to another account. Start a fresh one.
return api.models.create(model=model)
raise属于另一个账户的届会也回答同样的问题 404:查找范围是针对打电话者,因此一个账户无法达到甚至无法检测到另一个会话。
以内存创建的会话: 假
......它仍然存在, get() 仍然返回它, 因为配置已被记录。 没有的则是一个对话框: 重新打开它, 给您同样的设置和空白板块 。