feat(chat): display token usage and tps in message footers (#1094)
This commit is contained in:
24 files changed
+448
-3
No files matched your search
@@ -23,6 +23,8 @@ class ChatMessageMapperTest {
|
||||
toolName = "search",
|
||||
toolStatus = "RUNNING",
|
||||
isStreaming = true,
|
||||
tokenCount = 42,
|
||||
tps = 55.5,
|
||||
)
|
||||
|
||||
val ui = entity.toUiModel()
|
||||
@@ -35,6 +37,8 @@ class ChatMessageMapperTest {
|
||||
assertEquals("search", ui.toolName)
|
||||
assertEquals(ToolStatus.RUNNING, ui.toolStatus)
|
||||
assertTrue(ui.isStreaming)
|
||||
assertEquals(42, ui.tokenCount)
|
||||
assertEquals(55.5, ui.tps ?: 0.0, 0.001)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,6 +53,8 @@ class ChatMessageMapperTest {
|
||||
toolName = null,
|
||||
toolStatus = null,
|
||||
isStreaming = false,
|
||||
tokenCount = 100,
|
||||
tps = 24.8,
|
||||
)
|
||||
|
||||
val entity = ui.toEntity("session-b")
|
||||
@@ -62,6 +68,8 @@ class ChatMessageMapperTest {
|
||||
assertNull(entity.toolName)
|
||||
assertNull(entity.toolStatus)
|
||||
assertFalse(entity.isStreaming)
|
||||
assertEquals(100, entity.tokenCount)
|
||||
assertEquals(24.8, entity.tps ?: 0.0, 0.001)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -70,4 +70,19 @@ class HermesDatabaseMigrationsTest {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migration6to7_executesTokenCountAndTpsColumnAdditionOnSQLiteConnection() =
|
||||
runBlocking {
|
||||
val connection = mockk<SQLiteConnection>(relaxed = true)
|
||||
HermesDatabase.MIGRATION_6_7.migrate(connection)
|
||||
verify(exactly = 1) {
|
||||
connection.execSQL(
|
||||
"ALTER TABLE `chat_messages` ADD COLUMN `token_count` INTEGER",
|
||||
)
|
||||
connection.execSQL(
|
||||
"ALTER TABLE `chat_messages` ADD COLUMN `tps` REAL",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user