Chat session: add `session.reset()` for stateless single-turn requests

未关闭
#1,664 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@barhanc 已经在做这个了。

开始于 2026年11月27日。

评估

这个 Issue 还没有评估数据。

描述

feature request
Problem description

There is no way to clear a chat session. resetOnTurn: true sounds like it, but (as documented) it only forces full re-encoding: the session keeps the history and re-prefills all of it on every turn. Sending the same prompt four times gave 19, 45, 71 and 97 prefilled tokens. For independent single-turn requests (extraction, classification, benchmarks) the only way to get a clean context is to dispose and recreate the session.

Proposed solution

A session.reset() method that clears the history and KV cache back to initialMessages without reloading the model (react-native-litert-lm has resetConversation() for this), or an option that drops each turn from history after it completes. It would also help to state in the docs that resetOnTurn keeps and re-prefills the full history.

Alternative solutions

No response

Benefits to React Native ExecuTorch

Stateless requests are a common use of small on-device models, and recreating the session costs a model reload.

Additional context

No response

主要语言
TypeScript
星标
1.8k
派生
102
平均合并
2 天 6 小时
30 天内合并 PR
46

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

software-mansion/react-native-executorch 的其他 Issue

查看 software-mansion/react-native-executorch 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。