Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5878ec7a7f | |||
| 77b4f3d74f |
@@ -30,8 +30,8 @@ android {
|
||||
* versionCode 每次发版 +1(Android 靠它判断"能不能覆盖安装",
|
||||
* 改小了会装不上)。
|
||||
*/
|
||||
versionCode = 263
|
||||
versionName = "2.0.63"
|
||||
versionCode = 265
|
||||
versionName = "2.0.65"
|
||||
|
||||
ndk {
|
||||
// Chaquopy 只支持这两个;Termux bootstrap 也只准备了这两份
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
@@ -570,8 +570,40 @@ class AppViewModel(val client: KernelClient) : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun importPackage(kind: String, base64: String, textJson: String) {
|
||||
/**
|
||||
* 标记 / 取消标记第 [index] 条消息为「重要」(v1.2 §4.3)。
|
||||
*
|
||||
* ★ 被标记的消息在**上下文窗口裁剪**时破格永久携带 ——
|
||||
* 平时"攒够 5 轮裁 5 轮",这几条会一直留着。
|
||||
* 所以提示语要写清**效果**,不然用户不知道这个标记是干什么的。
|
||||
*/
|
||||
fun toggleImportant(index: Int) {
|
||||
val cid = activeConversationId
|
||||
val msg = messages.getOrNull(index) ?: return
|
||||
val cur = msg.important
|
||||
viewModelScope.launch {
|
||||
runCatching {
|
||||
// ★ 传**内容**不传下标:界面的列表和存储的不保证一一对应
|
||||
withContext(Dispatchers.IO) { client.markImportant(cid, msg.content, !cur) }
|
||||
}.onSuccess {
|
||||
// ★★ **本地也改一下**,不能只靠 refresh()。
|
||||
//
|
||||
// 界面上这份 `messages` 和存储里那份**本来就不是总同步**
|
||||
// (这一版之前就存在的行为),只 refresh 的话用户看不到
|
||||
// 那个「★ 重要」标记 —— 表现是"我标了但界面上没反应",
|
||||
// 而那正是最初把标记打到别人身上的同一个根因。
|
||||
messages.getOrNull(index)?.let { old ->
|
||||
messages[index] = old.copy(important = !cur)
|
||||
}
|
||||
showHint(
|
||||
if (!cur) "标成重要了 —— 以后裁剪上下文时这条会一直留着"
|
||||
else "取消标记了",
|
||||
)
|
||||
}.onFailure { showHint(it.message ?: "标不了") }
|
||||
}
|
||||
}
|
||||
|
||||
fun importPackage(kind: String, base64: String, textJson: String) { viewModelScope.launch {
|
||||
val msg = runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
when (kind) {
|
||||
|
||||
@@ -13,7 +13,9 @@ import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -576,11 +578,46 @@ private fun HeroSection(greeting: String) {
|
||||
/* ------------------------------ 消息 ------------------------------ */
|
||||
|
||||
@Composable
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
private fun MessageItem(vm: AppViewModel, index: Int, msg: ChatMessage, speech: SpeechController) {
|
||||
val clipboard = LocalClipboardManager.current
|
||||
val speaking = speech.speakingIndex == index
|
||||
// 长按气泡 → 这个菜单(v1.2 §4.3 的「标记重要」)
|
||||
var importantMenu by remember { mutableStateOf(false) }
|
||||
|
||||
if (msg.role == "user") {
|
||||
// ★ 长按**用户**消息才能标重要。需求说的是"消息操作栏加标记重要",
|
||||
// 这里只做用户那一侧,理由是**效果差异**:
|
||||
// 被标的消息在上下文窗口裁剪时破格携带,而 AI 的回复通常就在
|
||||
// 最近几轮里、本来就裁不到;用户想留住的是**很久以前问过的那句**。
|
||||
if (importantMenu) {
|
||||
androidx.compose.material3.AlertDialog(
|
||||
onDismissRequest = { importantMenu = false },
|
||||
title = { Text(if (msg.important) "这条标过了" else "这条消息") },
|
||||
text = {
|
||||
Text(
|
||||
if (msg.important) {
|
||||
"取消之后它就按普通消息处理了 —— 攒够一批会被裁掉。"
|
||||
} else {
|
||||
"标成重要之后,以后裁剪上下文时这条会一直留着," +
|
||||
"不管过了多少轮。"
|
||||
},
|
||||
fontSize = 13.sp,
|
||||
lineHeight = 19.sp,
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
androidx.compose.material3.TextButton(
|
||||
onClick = { vm.toggleImportant(index); importantMenu = false },
|
||||
) { Text(if (msg.important) "取消标记" else "标记重要", color = Doubao.Blue) }
|
||||
},
|
||||
dismissButton = {
|
||||
androidx.compose.material3.TextButton(
|
||||
onClick = { importantMenu = false },
|
||||
) { Text("算了") }
|
||||
},
|
||||
)
|
||||
}
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
|
||||
Column(horizontalAlignment = Alignment.End) {
|
||||
msg.attachments.forEach { file ->
|
||||
@@ -607,11 +644,25 @@ private fun MessageItem(vm: AppViewModel, index: Int, msg: ChatMessage, speech:
|
||||
.widthIn(max = 288.dp)
|
||||
.clip(RoundedCornerShape(18.dp, 18.dp, 4.dp, 18.dp))
|
||||
.background(Doubao.Blue)
|
||||
.combinedClickable(
|
||||
onClick = { clipboard.setText(AnnotatedString(msg.content)) },
|
||||
onLongClick = { importantMenu = true },
|
||||
)
|
||||
.padding(horizontal = 14.dp, vertical = 11.dp),
|
||||
) {
|
||||
Text(msg.content, color = Color.White, fontSize = 16.sp, lineHeight = 25.sp)
|
||||
}
|
||||
}
|
||||
// 标过的给一个小标记 —— 不然用户忘了自己标过哪几条,
|
||||
// 而"这条会不会被裁掉"是他自己决定的
|
||||
if (msg.important) {
|
||||
Spacer(Modifier.height(3.dp))
|
||||
Text(
|
||||
"★ 重要(不会被裁掉)",
|
||||
fontSize = 10.sp,
|
||||
color = Doubao.Blue,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.doubao.lynxclone.ui
|
||||
package com.doubao.lynxclone.ui
|
||||
|
||||
import android.util.Base64
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
@@ -102,6 +102,10 @@ private val MODEL_FIELDS = listOf(
|
||||
Field("apiKey", "API Key", "留空则用全局设置里那个", password = true),
|
||||
Field("provider", "提供商", "ark / openai / deepseek …(留空则跟随全局)"),
|
||||
Field("pricePerK", "单价(元/千 Token)", "留空 = 不显示费用估算", number = true),
|
||||
// ★ v1.2:命中缓存的单价单独填。各家命中都比未命中便宜得多(常见 1/10),
|
||||
// 不填的话费用按未命中的价格算 —— **越用越高估**,而用户会以为
|
||||
// 自己真花了那些钱。留空 = 按未命中单价算(保守估计,不会低估)。
|
||||
Field("cachePricePerK", "命中单价(元/千 Token)", "留空 = 按上面的单价算(偏保守)", number = true),
|
||||
Field(
|
||||
"noTools", "不支持工具调用",
|
||||
"这个模型不会 function calling(本地小模型、老网关常见)。打开之后不再传 tools," +
|
||||
|
||||
@@ -91,6 +91,24 @@ fun TokenUsageScreen(
|
||||
Spacer(Modifier.width(24.dp))
|
||||
Metric("输出", usage.output)
|
||||
}
|
||||
// ★ 缓存统计(v1.2):**这家没给就不显示**。
|
||||
// 不是每家都返回缓存字段,显示两个恒为 0 的数会让用户
|
||||
// 以为"缓存完全没生效" —— 那是假警报,比不显示更糟。
|
||||
if (usage.hasCacheInfo) {
|
||||
Spacer(Modifier.height(10.dp))
|
||||
Row {
|
||||
Metric("缓存命中", usage.cacheHit)
|
||||
Spacer(Modifier.width(24.dp))
|
||||
Metric("缓存未命中", usage.cacheMiss)
|
||||
}
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
"命中率 ${(usage.hitRate * 100).toInt()}% —— " +
|
||||
"命中缓存的输入便宜得多,这一段没白存",
|
||||
fontSize = 11.sp,
|
||||
color = Doubao.Blue,
|
||||
)
|
||||
}
|
||||
if (usage.pricePerK > 0 && usage.cost != null) {
|
||||
Spacer(Modifier.height(10.dp))
|
||||
Text(
|
||||
@@ -180,6 +198,18 @@ fun TokenUsageScreen(
|
||||
color = doubaoTextSecondary(),
|
||||
)
|
||||
}
|
||||
// ★ 缓存命中/未命中(v1.2)。**这家没给就不显示这一行** ——
|
||||
// 不是每家都返回缓存字段,显示一个恒为 0 的"命中率"
|
||||
// 会让用户以为"缓存完全没生效"(那是个假警报)
|
||||
if (m.hasCacheInfo) {
|
||||
Spacer(Modifier.height(2.dp))
|
||||
Text(
|
||||
"命中 ${fmtTokens(m.cacheHit)} · 未命中 ${fmtTokens(m.cacheMiss)}" +
|
||||
" · 命中率 ${(m.hitRate * 100).toInt()}%",
|
||||
fontSize = 11.sp,
|
||||
color = Doubao.Blue,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""智能体系统的 HTTP 接口(需求 v1.1)。
|
||||
"""智能体系统的 HTTP 接口(需求 v1.1)。
|
||||
|
||||
## 为什么单独一个模块
|
||||
|
||||
@@ -1074,6 +1074,9 @@ def _usage_payload(agent: dict) -> dict:
|
||||
used = usage['total']['input'] + usage['total']['output']
|
||||
# 单价(元/千 Token):在**全局模型列表**里配,填了才估费用
|
||||
price = 0.0
|
||||
cache_price = 0.0
|
||||
entry = {} # ★ 先给个空 dict:下面只有 mid 非空才会填它,
|
||||
# 而返回时无条件读 `entry` —— 不初始化会 NameError
|
||||
mid = agent.get('modelId') or ''
|
||||
if mid:
|
||||
entry = store.get_resource('models', mid) or {}
|
||||
@@ -1081,6 +1084,10 @@ def _usage_payload(agent: dict) -> dict:
|
||||
price = float(entry.get('pricePerK') or 0)
|
||||
except (TypeError, ValueError):
|
||||
price = 0.0
|
||||
try:
|
||||
cache_price = float(entry.get('cachePricePerK') or 0)
|
||||
except (TypeError, ValueError):
|
||||
cache_price = 0.0
|
||||
return {
|
||||
'agentId': agent.get('id') or '',
|
||||
'name': agent.get('name') or '',
|
||||
@@ -1089,6 +1096,10 @@ def _usage_payload(agent: dict) -> dict:
|
||||
# v1.2 缓存统计:两家都没给时是 0/0,界面据此不显示那一列
|
||||
'cacheHit': usage['total'].get('cacheHit', 0),
|
||||
'cacheMiss': usage['total'].get('cacheMiss', 0),
|
||||
# ★ 命中缓存的单价(v1.2)。各家命中都比未命中便宜得多(常见 1/10),
|
||||
# 只按未命中单价算的话费用会**越用越高估** —— 而用户会以为
|
||||
# 自己真花了那些钱。
|
||||
'cachePricePerK': cache_price,
|
||||
'total': used,
|
||||
'byModel': usage['byModel'],
|
||||
'limit': limit,
|
||||
|
||||
@@ -1030,6 +1030,51 @@ class KernelHandler(BaseHTTPRequestHandler):
|
||||
self.send_json(200 if ok else 404, {'ok': ok})
|
||||
return True
|
||||
|
||||
# 标记某条消息为「重要」(v1.2 §4.3)
|
||||
#
|
||||
# 路径:/api/conversations/<convId>/important,body: {content, role?, important?}
|
||||
#
|
||||
# ★ 只有**用户**能打这个标记(需求原话"仅用户可标")——
|
||||
# AI 那边没有对应的工具,它有 `memory_add` 去记该记的东西。
|
||||
# 被标记的消息在**上下文窗口裁剪**时"破格永久携带"。
|
||||
#
|
||||
# ★★ 按**内容**定位而不是下标(踩过):
|
||||
# 界面上那份消息列表和存储里的**不保证一一对应**(本地生成的内容、
|
||||
# 还没落地的流式消息……),按下标"长按第 3 条"会把标记打到第 1 条上,
|
||||
# 而且**静默标错** —— 用户要等哪天发现某句话莫名没被裁掉才知道。
|
||||
# 找不到就报 404,绝不猜一条标上去。
|
||||
if pathname.startswith('/api/conversations/') and pathname.endswith('/important') \
|
||||
and method == 'POST':
|
||||
cid = pathname[len('/api/conversations/'):-len('/important')].strip('/')
|
||||
if cid and '/' not in cid:
|
||||
try:
|
||||
body = self.read_json_body()
|
||||
except ValueError:
|
||||
body = {}
|
||||
content = body.get('content')
|
||||
if content is None:
|
||||
self.send_json(400, {'error': '要带上 content(按内容定位那条消息)'})
|
||||
return True
|
||||
want = body.get('important')
|
||||
if want is None:
|
||||
# 不传就取反:界面上是个开关,点一下切一次。
|
||||
# ★ 用**存储里**那条的当前状态取反(不是界面传来的),
|
||||
# 免得界面和服务端状态不一致时越切越乱
|
||||
conv = store.get_conversation(cid) or {}
|
||||
cur = False
|
||||
for m in reversed(conv.get('messages') or []):
|
||||
if str(m.get('content') or '') == str(content):
|
||||
cur = bool(m.get('important'))
|
||||
break
|
||||
want = not cur
|
||||
msg = store.mark_important_by_content(
|
||||
cid, content, str(body.get('role') or ''), bool(want))
|
||||
if msg is None:
|
||||
self.send_json(404, {'error': '没找到这条消息(内容对不上)'})
|
||||
else:
|
||||
self.send_json(200, {'ok': True, 'important': bool(want)})
|
||||
return True
|
||||
|
||||
# 会议模式
|
||||
if pathname == '/api/meetings' and method == 'GET':
|
||||
self.send_json(200, {'meetings': meeting.list_meetings()})
|
||||
|
||||
@@ -1015,6 +1015,72 @@ def append_messages(conv_id: str, messages: list):
|
||||
return item
|
||||
|
||||
|
||||
def mark_important(conv_id: str, index: int, important: bool):
|
||||
"""
|
||||
给第 [index] 条消息打/取消「重要」标记(v1.2 §4.3)。
|
||||
|
||||
★ 需求原话:"**仅用户可标**;被标记消息破格永久携带、按原始时间序插入"。
|
||||
所以这个函数**只由界面调**,AI 那边没有对应的工具 ——
|
||||
它有 `memory_add` 去记该记的东西,标记是用户的主权。
|
||||
|
||||
★★ 按**下标**定位是**不安全**的,已经踩过:界面上那份消息列表可能和
|
||||
存储里的**不是一一对应**(本地生成的内容、还没落地的流式消息……),
|
||||
于是"长按第 3 条"会把标记打到第 1 条上 —— **静默标错**,
|
||||
而用户完全看不出来(要等哪天发现某句话莫名没被裁掉)。
|
||||
所以界面走的是 `mark_important_by_content`,这个按下标的老函数
|
||||
只留给内部/测试用。
|
||||
"""
|
||||
item = get_conversation(conv_id)
|
||||
if not item:
|
||||
return None
|
||||
msgs = item.get('messages') or []
|
||||
if not (0 <= index < len(msgs)):
|
||||
return None
|
||||
with _lock:
|
||||
# ★ 只改这一个字段,**不动 content** —— 需求把"历史消息字节冻结"
|
||||
# 写成了内核纪律:改一个字,从那儿往后的前缀缓存全废。
|
||||
# 标一个 `important` 是**新增键**,不影响 content 的字节。
|
||||
msgs[index]['important'] = bool(important)
|
||||
item['updatedAt'] = now_iso()
|
||||
_persist_conversations()
|
||||
return msgs[index]
|
||||
|
||||
|
||||
def mark_important_by_content(conv_id: str, content: str, role: str = '',
|
||||
important: bool = True):
|
||||
"""
|
||||
按**内容**找那条消息来打标记(界面的长按走这条路)。
|
||||
|
||||
★ 为什么不用下标:见 `mark_important` 的说明 —— 界面的列表和存储的
|
||||
列表**不保证一一对应**,下标会静默标错。
|
||||
|
||||
★ 从**后往前**找:同一个内容可能重复出现(用户把一句话发了两遍),
|
||||
而他长按的通常是比较靠后的那条。
|
||||
|
||||
★ 找不到就返回 None,让调用方**报错** —— 绝不"猜一条"标上去。
|
||||
标错了用户看不出来,而那比报错糟得多。
|
||||
"""
|
||||
item = get_conversation(conv_id)
|
||||
if not item:
|
||||
return None
|
||||
want = _as_text(content)
|
||||
if not want:
|
||||
return None
|
||||
msgs = item.get('messages') or []
|
||||
hit = -1
|
||||
for i in range(len(msgs) - 1, -1, -1):
|
||||
m = msgs[i]
|
||||
if _as_text(m.get('content')) != want:
|
||||
continue
|
||||
if role and m.get('role') != role:
|
||||
continue
|
||||
hit = i
|
||||
break
|
||||
if hit < 0:
|
||||
return None
|
||||
return mark_important(conv_id, hit, important)
|
||||
|
||||
|
||||
def auto_title(conv_id: str, text: str) -> None:
|
||||
"""用首条用户消息自动起标题(只改还没起过名的会话)。"""
|
||||
item = get_conversation(conv_id)
|
||||
@@ -1242,7 +1308,11 @@ RESOURCES = {
|
||||
'file': lambda: paths.get().models_file,
|
||||
'key': 'models',
|
||||
'text': ('name', 'apiBase', 'apiKey', 'model', 'provider'),
|
||||
'num': ('pricePerK',), # 元/千 Token,0 = 不显示费用估算
|
||||
# 元/千 Token,0 = 不显示费用估算。
|
||||
# ★ cachePricePerK 是**命中缓存**的单价(v1.2):各家命中都比未命中
|
||||
# 便宜得多(常见 1/10)。只填一个输入单价的话,费用估算会按未命中
|
||||
# 的价格算 —— 用得越多、高估得越离谱,而用户会以为自己真花了那些钱。
|
||||
'num': ('pricePerK', 'cachePricePerK'),
|
||||
# ★ noTools:这个模型不支持 function calling(需求 3.3 的兼容降级)。
|
||||
# 打开之后不传 tools、改成正文内的调用约定 —— 见 agent_loop.DEGRADED_HINT。
|
||||
'bool': ('noTools',),
|
||||
|
||||
BIN
docs/screenshots/group-bar.png
Normal file
BIN
docs/screenshots/group-bar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
BIN
docs/screenshots/rulepack-edit.png
Normal file
BIN
docs/screenshots/rulepack-edit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
BIN
docs/screenshots/rulepacks.png
Normal file
BIN
docs/screenshots/rulepacks.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
@@ -132,6 +132,67 @@ def main():
|
||||
check("非 dict 的东西被跳过", W.trim([{'role': 'user'}, 'noise', None], 20)['kept'] == 1)
|
||||
check("describe 不炸", isinstance(W.describe(W.trim(convo(30), 20, 5)), str))
|
||||
|
||||
print("\n=== 8. 标记重要:从存储到裁剪的整条路 ===")
|
||||
#
|
||||
# 这一节测的是**端到端**:界面调接口 → 存库 → 裁剪时读它。
|
||||
# 中间任何一环断了,用户看到的现象都是"我标了,但它还是被裁掉了"。
|
||||
import store
|
||||
|
||||
conv = store.create_conversation('测试', agent_id='A')
|
||||
store.append_messages(conv['id'], [
|
||||
{'role': 'user', 'content': '记住这句'},
|
||||
{'role': 'assistant', 'content': '好的'},
|
||||
])
|
||||
check("新消息默认没标记", not (store.get_conversation(conv['id'])['messages'][0].get('important')))
|
||||
m = store.mark_important(conv['id'], 0, True)
|
||||
check("标记上了", m and m.get('important') is True, str(m))
|
||||
# ★ 关键:标记**不能动 content**(需求 4.3 的"字节冻结")
|
||||
check("**content 一个字节都没动**(字节冻结)", m.get('content') == '记住这句', str(m))
|
||||
check("越界下标返回 None(不抛异常)", store.mark_important(conv['id'], 99, True) is None)
|
||||
check("不存在的会话返回 None", store.mark_important('nope', 0, True) is None)
|
||||
check("能取消标记", store.mark_important(conv['id'], 0, False).get('important') is False)
|
||||
# 端到端:标过的消息在裁剪时被捞回
|
||||
msgs = []
|
||||
for i in range(30):
|
||||
msgs.append({'role': 'user', 'content': f'问{i}', 'important': i == 0})
|
||||
msgs.append({'role': 'assistant', 'content': f'答{i}'})
|
||||
r = W.trim(msgs, 20, 5)
|
||||
check("端到端:标记过的老消息**没被裁掉**",
|
||||
any(m['content'] == '问0' for m in r['messages']), str(r.get('rescued')))
|
||||
check("没标记的老消息被裁掉了", not any(m['content'] == '问5' for m in r['messages']))
|
||||
|
||||
print("\n=== 9. ★★ 按内容定位(下标定位踩过的坑)===")
|
||||
#
|
||||
# 界面上那份消息列表和存储里那份**不保证一一对应**(本地生成的内容、
|
||||
# 还没落地的流式消息……)。按下标"长按第 3 条"会把标记打到第 1 条上,
|
||||
# 而且**静默标错** —— 真机上就是这么错的。
|
||||
c3 = store.create_conversation('定位', agent_id='A')
|
||||
store.append_messages(c3['id'], [
|
||||
{'role': 'user', 'content': '第一句'},
|
||||
{'role': 'assistant', 'content': '回一句'},
|
||||
{'role': 'user', 'content': '第三句'},
|
||||
])
|
||||
m = store.mark_important_by_content(c3['id'], '第三句', 'user', True)
|
||||
check("按内容标到了**那一条**", m and m.get('content') == '第三句', str(m))
|
||||
flags = [(x['content'], bool(x.get('important')))
|
||||
for x in store.get_conversation(c3['id'])['messages']]
|
||||
check("**只标了那一条**(别的没被误标)",
|
||||
flags == [('第一句', False), ('回一句', False), ('第三句', True)], str(flags))
|
||||
check("内容对不上 → None(**绝不猜一条标上去**)",
|
||||
store.mark_important_by_content(c3['id'], '没有这句话', 'user', True) is None)
|
||||
check("空内容 → None", store.mark_important_by_content(c3['id'], '', 'user', True) is None)
|
||||
check("不存在的会话 → None", store.mark_important_by_content('nope', '第一句', 'user', True) is None)
|
||||
# 重复内容:从后往前找(用户长按的通常是靠后那条)
|
||||
c4 = store.create_conversation('重复', agent_id='A')
|
||||
store.append_messages(c4['id'], [
|
||||
{'role': 'user', 'content': '一样'},
|
||||
{'role': 'user', 'content': '别的'},
|
||||
{'role': 'user', 'content': '一样'},
|
||||
])
|
||||
store.mark_important_by_content(c4['id'], '一样', 'user', True)
|
||||
flags4 = [bool(x.get('important')) for x in store.get_conversation(c4['id'])['messages']]
|
||||
check("重复内容标**最后**一条(从后往前找)", flags4 == [False, False, True], str(flags4))
|
||||
|
||||
print()
|
||||
if fails:
|
||||
print(f"❌ {len(fails)} 项不合格:")
|
||||
|
||||
Reference in New Issue
Block a user