助理会期

getHistory()

assistant.getHistory() → Promise<{ ok, messages }>

本届会议上所说的一切都是为了保存的, 读起来没有增加什么,没有花费。

GET /api/ai/models/:id/messagesfreeoldest first
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

返回值

{
  ok: true,
  messages: [
    { role: "user",
      parts: [{ type: "text", content: "Résume ce contrat." },
              { type: "file", content: "", mime: "application/pdf", url: "…" }] },

    { role: "assistant",
      parts: [{ type: "text", content: "Le contrat porte sur…" }],
      model: "gemini-3.5-flash" }
  ]
}
{
    "ok": True,
    "messages": [
        {"role": "user",
         "parts": [{"type": "text", "content": "Résume ce contrat."},
                   {"type": "file", "content": "", "mime": "application/pdf", "url": "…"}]},

        {"role": "assistant",
         "parts": [{"type": "text", "content": "Le contrat porte sur…"}],
         "model": "gemini-3.5-flash"},
    ],
}
rolestring

user 或 assistant.

partsarray

信息,一个一个一个一个的 总是一个的

parts[].typestring

text · json · image · audio · video · file.

parts[].contentstring

文本。文本中不是文本的部分空。

parts[].mime · url · path · sourceIdstring

其非文本部分来自已知的某一部分。

modelstring

助理信息:哪个模型回答。

二进制引用,未储存

所发送的图片或所制作的片段被其参考文献所记住,而不是被其字节所记住。历史告诉你,一个图像是对话的一部分,并没有交回。

这不是您的文件归档文件

如果生成的图像很重要, 当生成时将其交给您时将其写入。 历史不会再给你第二次 。

长的文字也被捆绑在一起:非常长的讯息存储到一个限度, 标记为短短的过去。 对话继续有效; 存储的文本不是寄出的内容的字节 。

模型所看到的不是这个

这是记录,接下来的会发送到什么 generate() 后面是旧部分的概要,加上最近的信息——所以长篇会议在这里显示完整的历史,同时发送较短的信息。

getHistory()下一个电话发送什么
旧旧信息全部,按顺序排列以摘要取代,一旦其增长
最近的信息现 现 现 现 时现 现 现 现 时
二进二进参考不予再同意

用途

// Rebuild a thread in your own interface
const { messages } = await assistant.getHistory();

for (const m of messages) {
  const text = m.parts.filter((p) => p.type === "text").map((p) => p.content).join("\n");
  const files = m.parts.filter((p) => p.type !== "text");
  ui.append({ who: m.role, text, attachments: files.length });
}
# Rebuild a thread in your own interface
messages = assistant.get_history()["messages"]

for m in messages:
    text = "\n".join(p["content"] for p in m["parts"] if p["type"] == "text")
    files = [p for p in m["parts"] if p["type"] != "text"]
    ui.append(who=m["role"], text=text, attachments=len(files))
// Export a conversation before deleting it
const { messages } = await assistant.getHistory();
await fs.writeFile(`${assistant.id}.json`, JSON.stringify({ session: assistant.data, messages }, null, 2));
await assistant.destroy();
import json
from pathlib import Path

# Export a conversation before deleting it
messages = assistant.get_history()["messages"]
Path(f"{assistant.id}.json").write_text(
    json.dumps({"session": assistant.data, "messages": messages}, indent=2, ensure_ascii=False),
    encoding="utf-8",
)
assistant.destroy()

当空时

创建一个会话 memory: false 没有任何存储, 因此它总是回答空列表, 而不是错误。 会话中同样没有生成任何结果 。

错误

代码状态触发条件
discussion_not_found404此账户的届会不使用此ID 。