@lobehub/lobehub 2.0.0-next.32 → 2.0.0-next.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test.yml +1 -0
- package/CHANGELOG.md +33 -0
- package/apps/desktop/package.json +1 -1
- package/changelog/v1.json +12 -0
- package/docker-compose/local/.env.example +3 -0
- package/docs/self-hosting/server-database/docker-compose.mdx +29 -0
- package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +29 -0
- package/package.json +1 -1
- package/packages/const/src/hotkeys.ts +3 -3
- package/packages/const/src/models.ts +2 -2
- package/packages/const/src/utils/merge.ts +3 -3
- package/packages/conversation-flow/package.json +13 -0
- package/packages/conversation-flow/src/__tests__/fixtures/index.ts +48 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistant-chain-with-followup.json +56 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistant-with-tools.json +144 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/active-index-1.json +131 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-branch.json +96 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-user-branch.json +123 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/conversation.json +128 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/index.ts +14 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/nested.json +179 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/simple.json +85 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/with-tools.json +169 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/complex-scenario.json +107 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts +14 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/linear-conversation.json +59 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-chain-with-followup.json +135 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-with-tools.json +340 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/active-index-1.json +242 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-branch.json +208 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-user-branch.json +254 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/conversation.json +260 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/index.ts +14 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/nested.json +389 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/simple.json +224 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/with-tools.json +418 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/complex-scenario.json +239 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/linear-conversation.json +138 -0
- package/packages/conversation-flow/src/__tests__/parse.test.ts +97 -0
- package/packages/conversation-flow/src/index.ts +17 -0
- package/packages/conversation-flow/src/indexing.ts +58 -0
- package/packages/conversation-flow/src/parse.ts +53 -0
- package/packages/conversation-flow/src/structuring.ts +38 -0
- package/packages/conversation-flow/src/transformation/BranchResolver.ts +66 -0
- package/packages/conversation-flow/src/transformation/ContextTreeBuilder.ts +292 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +421 -0
- package/packages/conversation-flow/src/transformation/MessageCollector.ts +166 -0
- package/packages/conversation-flow/src/transformation/MessageTransformer.ts +177 -0
- package/packages/conversation-flow/src/transformation/__tests__/BranchResolver.test.ts +151 -0
- package/packages/conversation-flow/src/transformation/__tests__/ContextTreeBuilder.test.ts +385 -0
- package/packages/conversation-flow/src/transformation/__tests__/FlatListBuilder.test.ts +511 -0
- package/packages/conversation-flow/src/transformation/__tests__/MessageCollector.test.ts +220 -0
- package/packages/conversation-flow/src/transformation/__tests__/MessageTransformer.test.ts +287 -0
- package/packages/conversation-flow/src/transformation/index.ts +78 -0
- package/packages/conversation-flow/src/types/contextTree.ts +65 -0
- package/packages/conversation-flow/src/types/flatMessageList.ts +66 -0
- package/packages/conversation-flow/src/types/shared.ts +63 -0
- package/packages/conversation-flow/src/types.ts +36 -0
- package/packages/conversation-flow/vitest.config.mts +10 -0
- package/packages/types/src/message/common/metadata.ts +5 -1
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/index.tsx +3 -4
- package/src/envs/__tests__/app.test.ts +47 -13
- package/src/envs/app.ts +6 -0
- package/src/server/routers/async/__tests__/caller.test.ts +333 -0
- package/src/server/routers/async/caller.ts +2 -1
- package/src/server/routers/lambda/__tests__/integration/message.integration.test.ts +57 -57
- package/src/server/routers/lambda/message.ts +2 -2
- package/src/server/services/message/__tests__/index.test.ts +4 -4
- package/src/server/services/message/index.ts +1 -1
- package/src/services/message/index.ts +2 -3
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +8 -8
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +8 -8
- package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +1 -1
- package/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts +1 -1
- package/src/store/chat/slices/message/action.test.ts +7 -7
- package/src/store/chat/slices/message/action.ts +2 -2
- package/src/store/chat/slices/plugin/action.test.ts +7 -7
- package/src/store/chat/slices/plugin/action.ts +1 -1
- package/packages/context-engine/ARCHITECTURE.md +0 -425
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-301",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Compare the performance of bubble sort vs quicksort",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {},
|
|
10
|
+
"metadata": {
|
|
11
|
+
"compare": true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "msg-302",
|
|
16
|
+
"role": "assistant",
|
|
17
|
+
"content": "**Bubble Sort Analysis:**\n\n```python\ndef bubble_sort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n return arr\n```\n\n**Time Complexity:**\n- Best Case: O(n)\n- Average Case: O(n²)\n- Worst Case: O(n²)\n\n**Space Complexity:** O(1)\n\n**Pros:**\n- Simple to implement\n- No extra memory needed\n- Stable sorting algorithm\n\n**Cons:**\n- Very slow for large datasets\n- Not practical for real-world use",
|
|
18
|
+
"parentId": "msg-301",
|
|
19
|
+
"model": "gpt-4",
|
|
20
|
+
"provider": "openai",
|
|
21
|
+
"createdAt": 1704067205000,
|
|
22
|
+
"updatedAt": 1704067205000,
|
|
23
|
+
"meta": {},
|
|
24
|
+
"metadata": {
|
|
25
|
+
"totalInputTokens": 24,
|
|
26
|
+
"totalOutputTokens": 198,
|
|
27
|
+
"totalTokens": 222,
|
|
28
|
+
"cost": 0.00666,
|
|
29
|
+
"tps": 45.0,
|
|
30
|
+
"ttft": 456,
|
|
31
|
+
"duration": 4400,
|
|
32
|
+
"latency": 4856
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "msg-303",
|
|
37
|
+
"role": "assistant",
|
|
38
|
+
"content": "**QuickSort Analysis:**\n\n```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + middle + quicksort(right)\n```\n\n**Time Complexity:**\n- Best Case: O(n log n)\n- Average Case: O(n log n)\n- Worst Case: O(n²)\n\n**Space Complexity:** O(log n)\n\n**Pros:**\n- Very fast in practice\n- Good cache locality\n- Industry standard\n\n**Cons:**\n- Not stable by default\n- Worst case is rare but possible\n- Uses recursion",
|
|
39
|
+
"parentId": "msg-301",
|
|
40
|
+
"model": "claude-3-5-sonnet-20241022",
|
|
41
|
+
"provider": "anthropic",
|
|
42
|
+
"createdAt": 1704067205100,
|
|
43
|
+
"updatedAt": 1704067205100,
|
|
44
|
+
"meta": {},
|
|
45
|
+
"metadata": {
|
|
46
|
+
"totalInputTokens": 24,
|
|
47
|
+
"totalOutputTokens": 215,
|
|
48
|
+
"totalTokens": 239,
|
|
49
|
+
"cost": 0.001195,
|
|
50
|
+
"tps": 58.0,
|
|
51
|
+
"ttft": 312,
|
|
52
|
+
"duration": 3707,
|
|
53
|
+
"latency": 4019,
|
|
54
|
+
"activeColumn": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "msg-304",
|
|
59
|
+
"role": "assistant",
|
|
60
|
+
"content": "Let me run a benchmark test to compare these two sorting algorithms with real data.",
|
|
61
|
+
"parentId": "msg-301",
|
|
62
|
+
"model": "gpt-4",
|
|
63
|
+
"provider": "openai",
|
|
64
|
+
"tools": [
|
|
65
|
+
{
|
|
66
|
+
"id": "tool-benchmark-bubble",
|
|
67
|
+
"identifier": "code-runner",
|
|
68
|
+
"apiName": "runBenchmark",
|
|
69
|
+
"arguments": "{\"algorithm\":\"bubble_sort\",\"size\":1000}",
|
|
70
|
+
"type": "default"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "tool-benchmark-quick",
|
|
74
|
+
"identifier": "code-runner",
|
|
75
|
+
"apiName": "runBenchmark",
|
|
76
|
+
"arguments": "{\"algorithm\":\"quicksort\",\"size\":1000}",
|
|
77
|
+
"type": "default"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"createdAt": 1704067205200,
|
|
81
|
+
"updatedAt": 1704067205200,
|
|
82
|
+
"meta": {},
|
|
83
|
+
"metadata": {
|
|
84
|
+
"totalInputTokens": 24,
|
|
85
|
+
"totalOutputTokens": 38,
|
|
86
|
+
"totalTokens": 62,
|
|
87
|
+
"cost": 0.000186,
|
|
88
|
+
"tps": 52.0,
|
|
89
|
+
"ttft": 198,
|
|
90
|
+
"duration": 730,
|
|
91
|
+
"latency": 928
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "msg-305",
|
|
96
|
+
"role": "tool",
|
|
97
|
+
"tool_call_id": "tool-benchmark-bubble",
|
|
98
|
+
"content": "{\"algorithm\":\"bubble_sort\",\"arraySize\":1000,\"executionTime\":\"2.34s\",\"comparisons\":499500,\"swaps\":250000}",
|
|
99
|
+
"pluginState": {
|
|
100
|
+
"cached": false,
|
|
101
|
+
"executionTime": 2340
|
|
102
|
+
},
|
|
103
|
+
"parentId": "msg-304",
|
|
104
|
+
"createdAt": 1704067207540,
|
|
105
|
+
"updatedAt": 1704067207540,
|
|
106
|
+
"meta": {}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "msg-306",
|
|
110
|
+
"role": "tool",
|
|
111
|
+
"tool_call_id": "tool-benchmark-quick",
|
|
112
|
+
"content": "{\"algorithm\":\"quicksort\",\"arraySize\":1000,\"executionTime\":\"0.012s\",\"comparisons\":9976,\"recursionDepth\":12}",
|
|
113
|
+
"pluginState": {
|
|
114
|
+
"cached": false,
|
|
115
|
+
"executionTime": 12
|
|
116
|
+
},
|
|
117
|
+
"parentId": "msg-304",
|
|
118
|
+
"createdAt": 1704067207552,
|
|
119
|
+
"updatedAt": 1704067207552,
|
|
120
|
+
"meta": {}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "msg-307",
|
|
124
|
+
"role": "assistant",
|
|
125
|
+
"content": "**Benchmark Results (Array Size: 1000):**\n\n**Bubble Sort:**\n- Execution Time: 2.34 seconds\n- Comparisons: 499,500\n- Swaps: 250,000\n\n**QuickSort:**\n- Execution Time: 0.012 seconds\n- Comparisons: 9,976\n- Recursion Depth: 12\n\n**Conclusion:** QuickSort is approximately **195x faster** than Bubble Sort for an array of 1000 elements. This demonstrates why QuickSort is the industry standard for general-purpose sorting.",
|
|
126
|
+
"parentId": "msg-306",
|
|
127
|
+
"createdAt": 1704067208000,
|
|
128
|
+
"updatedAt": 1704067208000,
|
|
129
|
+
"meta": {},
|
|
130
|
+
"metadata": {
|
|
131
|
+
"totalInputTokens": 156,
|
|
132
|
+
"totalOutputTokens": 134,
|
|
133
|
+
"totalTokens": 290,
|
|
134
|
+
"cost": 0.00087,
|
|
135
|
+
"tps": 48.0,
|
|
136
|
+
"ttft": 234,
|
|
137
|
+
"duration": 2791,
|
|
138
|
+
"latency": 3025
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"id": "msg-308",
|
|
143
|
+
"role": "user",
|
|
144
|
+
"content": "Great analysis! Can you explain why QuickSort has better cache locality?",
|
|
145
|
+
"parentId": "msg-303",
|
|
146
|
+
"createdAt": 1704067220000,
|
|
147
|
+
"updatedAt": 1704067220000,
|
|
148
|
+
"meta": {}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "msg-309",
|
|
152
|
+
"role": "assistant",
|
|
153
|
+
"content": "Excellent question! QuickSort has better cache locality because:\n\n1. **Sequential Access**: QuickSort processes array elements sequentially during partitioning, which means the CPU can prefetch nearby memory locations into cache.\n\n2. **In-place Partitioning**: Elements are rearranged within the same array, keeping data in the same memory region.\n\n3. **Smaller Working Set**: As QuickSort divides the array, it works on smaller subarrays that fit better in CPU cache.\n\n4. **Cache Lines**: Modern CPUs load data in cache lines (typically 64 bytes). QuickSort's sequential access pattern means when you access one element, nearby elements are already cached.\n\nIn contrast, some sorting algorithms like merge sort need to copy data to auxiliary arrays, causing more cache misses.",
|
|
154
|
+
"parentId": "msg-308",
|
|
155
|
+
"createdAt": 1704067222000,
|
|
156
|
+
"updatedAt": 1704067222000,
|
|
157
|
+
"meta": {},
|
|
158
|
+
"metadata": {
|
|
159
|
+
"totalInputTokens": 268,
|
|
160
|
+
"totalOutputTokens": 176,
|
|
161
|
+
"totalTokens": 444,
|
|
162
|
+
"cost": 0.00222,
|
|
163
|
+
"tps": 52.0,
|
|
164
|
+
"ttft": 312,
|
|
165
|
+
"duration": 3384,
|
|
166
|
+
"latency": 3696
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-501",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Help me debug this Python code that's throwing an error",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-502",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "I'll help you debug the code. Let me first check the syntax and run some analysis.",
|
|
15
|
+
"parentId": "msg-501",
|
|
16
|
+
"tools": [
|
|
17
|
+
{
|
|
18
|
+
"id": "tool-lint",
|
|
19
|
+
"identifier": "code-analyzer",
|
|
20
|
+
"apiName": "analyzePython",
|
|
21
|
+
"arguments": "{\"action\":\"lint\"}",
|
|
22
|
+
"type": "default"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "tool-test",
|
|
26
|
+
"identifier": "code-analyzer",
|
|
27
|
+
"apiName": "runTests",
|
|
28
|
+
"arguments": "{\"action\":\"test\"}",
|
|
29
|
+
"type": "default"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"createdAt": 1704067202000,
|
|
33
|
+
"updatedAt": 1704067202000,
|
|
34
|
+
"meta": {},
|
|
35
|
+
"usage": {
|
|
36
|
+
"totalInputTokens": 32,
|
|
37
|
+
"totalOutputTokens": 48,
|
|
38
|
+
"totalTokens": 80,
|
|
39
|
+
"cost": 0.00024
|
|
40
|
+
},
|
|
41
|
+
"performance": {
|
|
42
|
+
"tps": 45.0
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "msg-503",
|
|
47
|
+
"role": "tool",
|
|
48
|
+
"tool_call_id": "tool-lint",
|
|
49
|
+
"content": "{\"status\":\"success\",\"issues\":[{\"line\":15,\"message\":\"undefined variable 'result'\"}]}",
|
|
50
|
+
"pluginState": { "cached": false },
|
|
51
|
+
"parentId": "msg-502",
|
|
52
|
+
"createdAt": 1704067203000,
|
|
53
|
+
"updatedAt": 1704067203000,
|
|
54
|
+
"meta": {}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "msg-504",
|
|
58
|
+
"role": "tool",
|
|
59
|
+
"tool_call_id": "tool-test",
|
|
60
|
+
"content": "{\"status\":\"failed\",\"error\":\"NameError: name 'result' is not defined\"}",
|
|
61
|
+
"pluginState": { "cached": false },
|
|
62
|
+
"pluginError": { "type": "NameError", "message": "name 'result' is not defined" },
|
|
63
|
+
"parentId": "msg-502",
|
|
64
|
+
"createdAt": 1704067203100,
|
|
65
|
+
"updatedAt": 1704067203100,
|
|
66
|
+
"meta": {}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "msg-505",
|
|
70
|
+
"role": "user",
|
|
71
|
+
"content": "Here's the code:\n```python\ndef calculate():\n x = 5\n y = 10\n print(result)\n```",
|
|
72
|
+
"parentId": "msg-504",
|
|
73
|
+
"createdAt": 1704067210000,
|
|
74
|
+
"updatedAt": 1704067210000,
|
|
75
|
+
"meta": {}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "msg-506",
|
|
79
|
+
"role": "assistant",
|
|
80
|
+
"content": "I found the issue! On line 15, you're trying to use `result` but it's never defined. Here's the fix:\n\n```python\ndef calculate():\n x = 5\n y = 10\n result = x + y # Define result before using it\n print(result)\n```",
|
|
81
|
+
"parentId": "msg-505",
|
|
82
|
+
"createdAt": 1704067213000,
|
|
83
|
+
"updatedAt": 1704067213000,
|
|
84
|
+
"meta": {},
|
|
85
|
+
"usage": {
|
|
86
|
+
"totalInputTokens": 156,
|
|
87
|
+
"totalOutputTokens": 89,
|
|
88
|
+
"totalTokens": 245,
|
|
89
|
+
"cost": 0.000735
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "msg-507",
|
|
94
|
+
"role": "assistant",
|
|
95
|
+
"content": "Alternatively, you could return the value instead:\n\n```python\ndef calculate():\n x = 5\n y = 10\n return x + y\n\nresult = calculate()\nprint(result)\n```",
|
|
96
|
+
"parentId": "msg-505",
|
|
97
|
+
"createdAt": 1704067213100,
|
|
98
|
+
"updatedAt": 1704067213100,
|
|
99
|
+
"meta": {},
|
|
100
|
+
"usage": {
|
|
101
|
+
"totalInputTokens": 156,
|
|
102
|
+
"totalOutputTokens": 72,
|
|
103
|
+
"totalTokens": 228,
|
|
104
|
+
"cost": 0.000684
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Message } from '../../../types';
|
|
2
|
+
import assistantWithTools from './assistant-with-tools.json';
|
|
3
|
+
import { branch } from './branch';
|
|
4
|
+
import { compare } from './compare';
|
|
5
|
+
import complexScenario from './complex-scenario.json';
|
|
6
|
+
import linearConversation from './linear-conversation.json';
|
|
7
|
+
|
|
8
|
+
export const inputs = {
|
|
9
|
+
assistantWithTools: assistantWithTools as Message[],
|
|
10
|
+
branch,
|
|
11
|
+
compare,
|
|
12
|
+
complexScenario: complexScenario as Message[],
|
|
13
|
+
linearConversation: linearConversation as Message[],
|
|
14
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-001",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Can you help me write a Python function to check if a number is prime?",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-002",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "I'd be happy to help you write a function to check if a number is prime. Here's a simple and efficient implementation:\n\n```python\ndef is_prime(n):\n if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n \n for i in range(3, int(n**0.5) + 1, 2):\n if n % i == 0:\n return False\n \n return True\n```\n\nThis function works by checking divisibility up to the square root of the number.",
|
|
15
|
+
"parentId": "msg-001",
|
|
16
|
+
"createdAt": 1704067205000,
|
|
17
|
+
"updatedAt": 1704067205000,
|
|
18
|
+
"meta": {},
|
|
19
|
+
"usage": {
|
|
20
|
+
"totalInputTokens": 24,
|
|
21
|
+
"totalOutputTokens": 156,
|
|
22
|
+
"totalTokens": 180,
|
|
23
|
+
"cost": 0.00054
|
|
24
|
+
},
|
|
25
|
+
"performance": {
|
|
26
|
+
"tps": 52.0,
|
|
27
|
+
"ttft": 234,
|
|
28
|
+
"duration": 3000,
|
|
29
|
+
"latency": 3234
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "msg-003",
|
|
34
|
+
"role": "user",
|
|
35
|
+
"content": "Thanks! Can you add some test cases?",
|
|
36
|
+
"parentId": "msg-002",
|
|
37
|
+
"createdAt": 1704067210000,
|
|
38
|
+
"updatedAt": 1704067210000,
|
|
39
|
+
"meta": {}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "msg-004",
|
|
43
|
+
"role": "assistant",
|
|
44
|
+
"content": "Sure! Here are some test cases:\n\n```python\nprint(is_prime(2)) # True\nprint(is_prime(17)) # True\nprint(is_prime(100)) # False\nprint(is_prime(1)) # False\nprint(is_prime(-5)) # False\n```",
|
|
45
|
+
"parentId": "msg-003",
|
|
46
|
+
"createdAt": 1704067213000,
|
|
47
|
+
"updatedAt": 1704067213000,
|
|
48
|
+
"meta": {},
|
|
49
|
+
"usage": {
|
|
50
|
+
"totalInputTokens": 180,
|
|
51
|
+
"totalOutputTokens": 89,
|
|
52
|
+
"totalTokens": 269,
|
|
53
|
+
"cost": 0.000807
|
|
54
|
+
},
|
|
55
|
+
"performance": {
|
|
56
|
+
"tps": 44.5
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-chain-with-followup.json
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contextTree": [
|
|
3
|
+
{
|
|
4
|
+
"id": "msg-1",
|
|
5
|
+
"type": "message"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"id": "msg-2",
|
|
11
|
+
"type": "message",
|
|
12
|
+
"tools": ["tool-1"]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "msg-3",
|
|
16
|
+
"type": "message"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"id": "msg-2",
|
|
20
|
+
"type": "assistantGroup"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "msg-4",
|
|
24
|
+
"type": "message"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"flatList": [
|
|
28
|
+
{
|
|
29
|
+
"id": "msg-1",
|
|
30
|
+
"role": "user",
|
|
31
|
+
"content": "What's the weather?",
|
|
32
|
+
"createdAt": 1000,
|
|
33
|
+
"updatedAt": 1000,
|
|
34
|
+
"meta": {}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "msg-2",
|
|
38
|
+
"role": "assistantGroup",
|
|
39
|
+
"content": "",
|
|
40
|
+
"createdAt": 2000,
|
|
41
|
+
"updatedAt": 2000,
|
|
42
|
+
"parentId": "msg-1",
|
|
43
|
+
"meta": {},
|
|
44
|
+
"children": [
|
|
45
|
+
{
|
|
46
|
+
"content": "Let me check the weather for you.",
|
|
47
|
+
"id": "msg-2",
|
|
48
|
+
"tools": [
|
|
49
|
+
{
|
|
50
|
+
"id": "tool-1",
|
|
51
|
+
"type": "default",
|
|
52
|
+
"apiName": "getWeather",
|
|
53
|
+
"identifier": "weather",
|
|
54
|
+
"arguments": "{\"location\":\"New York\"}",
|
|
55
|
+
"result": {
|
|
56
|
+
"content": "{\"temperature\":\"72F\",\"condition\":\"sunny\"}",
|
|
57
|
+
"id": "tool-1"
|
|
58
|
+
},
|
|
59
|
+
"result_msg_id": "tool-1"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"content": "The weather in New York is 72F and sunny.",
|
|
65
|
+
"id": "msg-3"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "msg-4",
|
|
71
|
+
"role": "user",
|
|
72
|
+
"content": "Thanks! How about tomorrow?",
|
|
73
|
+
"createdAt": 5000,
|
|
74
|
+
"updatedAt": 5000,
|
|
75
|
+
"parentId": "msg-3",
|
|
76
|
+
"meta": {}
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"messageMap": {
|
|
80
|
+
"msg-1": {
|
|
81
|
+
"id": "msg-1",
|
|
82
|
+
"role": "user",
|
|
83
|
+
"content": "What's the weather?",
|
|
84
|
+
"createdAt": 1000,
|
|
85
|
+
"updatedAt": 1000,
|
|
86
|
+
"meta": {}
|
|
87
|
+
},
|
|
88
|
+
"msg-2": {
|
|
89
|
+
"id": "msg-2",
|
|
90
|
+
"role": "assistant",
|
|
91
|
+
"content": "Let me check the weather for you.",
|
|
92
|
+
"createdAt": 2000,
|
|
93
|
+
"updatedAt": 2000,
|
|
94
|
+
"parentId": "msg-1",
|
|
95
|
+
"meta": {},
|
|
96
|
+
"tools": [
|
|
97
|
+
{
|
|
98
|
+
"id": "tool-1",
|
|
99
|
+
"type": "default",
|
|
100
|
+
"apiName": "getWeather",
|
|
101
|
+
"identifier": "weather",
|
|
102
|
+
"arguments": "{\"location\":\"New York\"}"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"tool-1": {
|
|
107
|
+
"id": "tool-1",
|
|
108
|
+
"role": "tool",
|
|
109
|
+
"content": "{\"temperature\":\"72F\",\"condition\":\"sunny\"}",
|
|
110
|
+
"createdAt": 3000,
|
|
111
|
+
"updatedAt": 3000,
|
|
112
|
+
"parentId": "msg-2",
|
|
113
|
+
"meta": {},
|
|
114
|
+
"tool_call_id": "tool-1"
|
|
115
|
+
},
|
|
116
|
+
"msg-3": {
|
|
117
|
+
"id": "msg-3",
|
|
118
|
+
"role": "assistant",
|
|
119
|
+
"content": "The weather in New York is 72F and sunny.",
|
|
120
|
+
"createdAt": 4000,
|
|
121
|
+
"updatedAt": 4000,
|
|
122
|
+
"parentId": "tool-1",
|
|
123
|
+
"meta": {}
|
|
124
|
+
},
|
|
125
|
+
"msg-4": {
|
|
126
|
+
"id": "msg-4",
|
|
127
|
+
"role": "user",
|
|
128
|
+
"content": "Thanks! How about tomorrow?",
|
|
129
|
+
"createdAt": 5000,
|
|
130
|
+
"updatedAt": 5000,
|
|
131
|
+
"parentId": "msg-3",
|
|
132
|
+
"meta": {}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|