feat(text-asset): 支持文本类文件上传并作为会话上下文#719
Open
wynxing wants to merge 3 commits into
Open
Conversation
- 新增 TextAssetWhitelist/TextAssetPolicy 白名单与限额策略 - 支持 txt/md/json/yaml/yml/csv 文本附件(可配置开关) - 文本 asset 在提交前内联到 conversation parts - 前端 ChatInput/MessageItem 支持文本文件选择与展示 - 配置项:TextAssetEnabled、MaxTextAssetBytes/Chars - 更新 gateway RPC API 与配置文档
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
- 移除 gateway 硬编码文本大小拦截,由 runtime TextAssetPolicy 统一处理 - text_asset_enabled=false 时丢弃文本 asset image part,避免非 image/* mime 进入 provider 失败 - 丢弃时 emit EventError 通知用户
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #701
概述
复用已有的图片上传入口与 session asset 存储链路,新增文本类文件(
.txt/.md/.json/.yaml/.yml/.csv)支持。Runtime 在提交会话前将文本 asset 按 UTF-8 解码并内联为普通 text content part,Provider 层不感知"文件"概念。变更内容
Go 后端
策略层 (
session/assets_policy.go)TextAssetWhitelist:扩展名↔MIME 双向白名单,支持WithExtensions不可变扩展TextAssetPolicy:字节/字符上限、截断策略、文件名长度限制存储层 (
session/asset_store.go,session/sqlite_store.go,session/asset_text.go)AssetStore新增SetTextAssetPolicy接口输入准备 (
session/input_preparer.go,runtime/input_prepare.go)TextAssetCount字段Runtime (
runtime/text_assets.go)Config (
config/runtime.go)TextAssetEnabled开关(默认开启)MaxTextAssetBytes/MaxTextAssetChars可配置限额Gateway (
gateway/network_server.go)Web 前端
resolveAttachmentKind、acceptedTextMimeTypes、文本附件限额formatBytes工具函数文档
docs/gateway-rpc-api.md:更新 RPC API 文本附件说明docs/guides/configuration.md:新增文本附件配置项文档验收清单
go test ./...通过测试
回滚
保留上传存储能力,关闭
TextAssetEnabled配置项即可禁用文本 asset 转上下文逻辑。