Functions§
- append_
to_ file - 追加内容到文件,带错误处理
- atomic_
write_ file - 原子写入文件内容(先写入临时文件,然后重命名)
- create_
backup_ path - 创建带时间戳的备份文件路径
- current_
timestamp - 生成当前时间戳 (ISO 8601 格式)
- delete_
file - 删除文件,带错误处理
- deserialize_
from_ str - 反序列化 JSON 字符串到值,带错误处理
- ensure_
data_ dir_ exists - 确保数据目录存在
- ensure_
dir_ exists - 创建目录(如果不存在)
- estimate_
json_ token_ count - 估算 JSON 值的 token 数量
- estimate_
text_ tokens - 估算文本的 token 数量(区分中文字符) 对于中文字符,1字符≈1token;对于非中文字符,4字符≈1token
- estimate_
token_ count - 估算文本的 token 数量 这是一个简化的实现,实际应用中可以使用更精确的 token 计算器
- file_
exists - 检查文件是否存在
- generate_
session_ id - 生成随机会话 ID
- get_
data_ dir_ from_ env - 从环境变量获取数据目录路径
- get_
env_ var - 获取环境变量值,如果不存在则返回默认值
- get_
recent_ messages_ count_ from_ env - 从环境变量获取最近消息数量
- get_
session_ file_ path - 获取会话文件路径
- get_
summary_ threshold_ from_ env - 从环境变量获取摘要阈值
- parse_
timestamp - 解析时间戳字符串
- read_
file_ content - 异步读取文件内容,带错误处理
- serialize_
to_ string - 序列化 JSON 值到字符串,带错误处理
- write_
file_ content - 异步写入文件内容,带错误处理