@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,96 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-401",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Can you help me write a function to calculate fibonacci?",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-402",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "I'll help you write a fibonacci function.",
|
|
15
|
+
"parentId": "msg-401",
|
|
16
|
+
"createdAt": 1704067202000,
|
|
17
|
+
"updatedAt": 1704067202000,
|
|
18
|
+
"meta": {},
|
|
19
|
+
"metadata": {
|
|
20
|
+
"totalInputTokens": 15,
|
|
21
|
+
"totalOutputTokens": 12,
|
|
22
|
+
"totalTokens": 27,
|
|
23
|
+
"cost": 0.00008,
|
|
24
|
+
"activeBranchIndex": 1
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "msg-403",
|
|
29
|
+
"role": "assistant",
|
|
30
|
+
"content": "Here's a recursive implementation:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)\n```",
|
|
31
|
+
"parentId": "msg-402",
|
|
32
|
+
"createdAt": 1704067205000,
|
|
33
|
+
"updatedAt": 1704067205000,
|
|
34
|
+
"meta": {},
|
|
35
|
+
"metadata": {
|
|
36
|
+
"totalInputTokens": 30,
|
|
37
|
+
"totalOutputTokens": 45,
|
|
38
|
+
"totalTokens": 75,
|
|
39
|
+
"cost": 0.00022
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "msg-404",
|
|
44
|
+
"role": "assistant",
|
|
45
|
+
"content": "Here's an iterative approach which is more efficient:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n a, b = 0, 1\n for _ in range(2, n + 1):\n a, b = b, a + b\n return b\n```",
|
|
46
|
+
"parentId": "msg-402",
|
|
47
|
+
"createdAt": 1704067205100,
|
|
48
|
+
"updatedAt": 1704067205100,
|
|
49
|
+
"meta": {},
|
|
50
|
+
"metadata": {
|
|
51
|
+
"totalInputTokens": 30,
|
|
52
|
+
"totalOutputTokens": 52,
|
|
53
|
+
"totalTokens": 82,
|
|
54
|
+
"cost": 0.00025
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "msg-405",
|
|
59
|
+
"role": "assistant",
|
|
60
|
+
"content": "Let me show you a dynamic programming solution:\n\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n dp = [0, 1]\n for i in range(2, n + 1):\n dp.append(dp[i-1] + dp[i-2])\n return dp[n]\n```",
|
|
61
|
+
"parentId": "msg-402",
|
|
62
|
+
"createdAt": 1704067205200,
|
|
63
|
+
"updatedAt": 1704067205200,
|
|
64
|
+
"meta": {},
|
|
65
|
+
"metadata": {
|
|
66
|
+
"totalInputTokens": 30,
|
|
67
|
+
"totalOutputTokens": 58,
|
|
68
|
+
"totalTokens": 88,
|
|
69
|
+
"cost": 0.00026
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "msg-406",
|
|
74
|
+
"role": "user",
|
|
75
|
+
"content": "The iterative approach looks good! Can you add some comments?",
|
|
76
|
+
"parentId": "msg-404",
|
|
77
|
+
"createdAt": 1704067215000,
|
|
78
|
+
"updatedAt": 1704067215000,
|
|
79
|
+
"meta": {}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "msg-407",
|
|
83
|
+
"role": "assistant",
|
|
84
|
+
"content": "Sure! Here's the commented version:\n\n```python\ndef fibonacci(n):\n # Base cases\n if n <= 1:\n return n\n \n # Initialize first two fibonacci numbers\n a, b = 0, 1\n \n # Iterate from 2 to n\n for _ in range(2, n + 1):\n # Calculate next fibonacci number\n a, b = b, a + b\n \n return b\n```",
|
|
85
|
+
"parentId": "msg-406",
|
|
86
|
+
"createdAt": 1704067217000,
|
|
87
|
+
"updatedAt": 1704067217000,
|
|
88
|
+
"meta": {},
|
|
89
|
+
"metadata": {
|
|
90
|
+
"totalInputTokens": 95,
|
|
91
|
+
"totalOutputTokens": 78,
|
|
92
|
+
"totalTokens": 173,
|
|
93
|
+
"cost": 0.00052
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-user-branch.json
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-501",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "What's the difference between map and forEach in JavaScript?",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-502",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "The main difference is that `map()` returns a new array with transformed elements, while `forEach()` just iterates and returns undefined. Map is better for transformations, forEach is better for side effects.",
|
|
15
|
+
"parentId": "msg-501",
|
|
16
|
+
"createdAt": 1704067202000,
|
|
17
|
+
"updatedAt": 1704067202000,
|
|
18
|
+
"meta": {},
|
|
19
|
+
"metadata": {
|
|
20
|
+
"totalInputTokens": 18,
|
|
21
|
+
"totalOutputTokens": 42,
|
|
22
|
+
"totalTokens": 60,
|
|
23
|
+
"cost": 0.00018,
|
|
24
|
+
"activeBranchIndex": 1
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "msg-503",
|
|
29
|
+
"role": "user",
|
|
30
|
+
"content": "Can you show me a practical example?",
|
|
31
|
+
"parentId": "msg-502",
|
|
32
|
+
"createdAt": 1704067210000,
|
|
33
|
+
"updatedAt": 1704067210000,
|
|
34
|
+
"meta": {}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "msg-504",
|
|
38
|
+
"role": "assistant",
|
|
39
|
+
"content": "Sure! Here's a practical example:\n\n```javascript\nconst numbers = [1, 2, 3, 4, 5];\n\n// Using map - creates new array\nconst doubled = numbers.map(n => n * 2);\nconsole.log(doubled); // [2, 4, 6, 8, 10]\n\n// Using forEach - just iterates\nnumbers.forEach(n => console.log(n * 2));\n// Prints: 2, 4, 6, 8, 10\n```",
|
|
40
|
+
"parentId": "msg-503",
|
|
41
|
+
"createdAt": 1704067212000,
|
|
42
|
+
"updatedAt": 1704067212000,
|
|
43
|
+
"meta": {},
|
|
44
|
+
"metadata": {
|
|
45
|
+
"totalInputTokens": 68,
|
|
46
|
+
"totalOutputTokens": 95,
|
|
47
|
+
"totalTokens": 163,
|
|
48
|
+
"cost": 0.00049
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "msg-505",
|
|
53
|
+
"role": "user",
|
|
54
|
+
"content": "Thanks! What about performance differences?",
|
|
55
|
+
"parentId": "msg-504",
|
|
56
|
+
"createdAt": 1704067220000,
|
|
57
|
+
"updatedAt": 1704067220000,
|
|
58
|
+
"meta": {}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "msg-506",
|
|
62
|
+
"role": "assistant",
|
|
63
|
+
"content": "Performance-wise, forEach is slightly faster because it doesn't create a new array. However, the difference is negligible for most use cases. Choose based on functionality: use map when you need the transformed array, use forEach when you just need to iterate.",
|
|
64
|
+
"parentId": "msg-505",
|
|
65
|
+
"createdAt": 1704067222000,
|
|
66
|
+
"updatedAt": 1704067222000,
|
|
67
|
+
"meta": {},
|
|
68
|
+
"metadata": {
|
|
69
|
+
"totalInputTokens": 175,
|
|
70
|
+
"totalOutputTokens": 58,
|
|
71
|
+
"totalTokens": 233,
|
|
72
|
+
"cost": 0.0007
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "msg-507",
|
|
77
|
+
"role": "user",
|
|
78
|
+
"content": "Can you explain the technical implementation details?",
|
|
79
|
+
"parentId": "msg-502",
|
|
80
|
+
"createdAt": 1704067210100,
|
|
81
|
+
"updatedAt": 1704067210100,
|
|
82
|
+
"meta": {}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "msg-508",
|
|
86
|
+
"role": "assistant",
|
|
87
|
+
"content": "Certainly! From a technical perspective:\n\n**map():**\n- Allocates a new array in memory\n- Iterates through each element\n- Applies the callback function\n- Stores the result in the new array\n- Returns the new array\n\n**forEach():**\n- Iterates through each element\n- Applies the callback function\n- Discards the return value\n- Returns undefined",
|
|
88
|
+
"parentId": "msg-507",
|
|
89
|
+
"createdAt": 1704067212100,
|
|
90
|
+
"updatedAt": 1704067212100,
|
|
91
|
+
"meta": {},
|
|
92
|
+
"metadata": {
|
|
93
|
+
"totalInputTokens": 68,
|
|
94
|
+
"totalOutputTokens": 82,
|
|
95
|
+
"totalTokens": 150,
|
|
96
|
+
"cost": 0.00045
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "msg-509",
|
|
101
|
+
"role": "user",
|
|
102
|
+
"content": "What about memory usage?",
|
|
103
|
+
"parentId": "msg-508",
|
|
104
|
+
"createdAt": 1704067220100,
|
|
105
|
+
"updatedAt": 1704067220100,
|
|
106
|
+
"meta": {}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "msg-510",
|
|
110
|
+
"role": "assistant",
|
|
111
|
+
"content": "Great question! Map uses more memory because it creates a new array. If you have a large dataset (millions of items) and don't need the result array, forEach is more memory-efficient. However, if you're doing functional programming and need immutability, the memory overhead of map is usually worth it.",
|
|
112
|
+
"parentId": "msg-509",
|
|
113
|
+
"createdAt": 1704067222100,
|
|
114
|
+
"updatedAt": 1704067222100,
|
|
115
|
+
"meta": {},
|
|
116
|
+
"metadata": {
|
|
117
|
+
"totalInputTokens": 160,
|
|
118
|
+
"totalOutputTokens": 68,
|
|
119
|
+
"totalTokens": 228,
|
|
120
|
+
"cost": 0.00068
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-201",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Write a haiku about programming",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-202",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "Code flows like water,\nBugs hide in silent shadows,\nDebug brings the light.",
|
|
15
|
+
"parentId": "msg-201",
|
|
16
|
+
"createdAt": 1704067203000,
|
|
17
|
+
"updatedAt": 1704067203000,
|
|
18
|
+
"meta": {},
|
|
19
|
+
"metadata": {
|
|
20
|
+
"totalInputTokens": 12,
|
|
21
|
+
"totalOutputTokens": 28,
|
|
22
|
+
"totalTokens": 40,
|
|
23
|
+
"cost": 0.00012
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "msg-203",
|
|
28
|
+
"role": "assistant",
|
|
29
|
+
"content": "Functions compile,\nVariables dance in memory,\nAlgorithm sings.",
|
|
30
|
+
"parentId": "msg-201",
|
|
31
|
+
"createdAt": 1704067203100,
|
|
32
|
+
"updatedAt": 1704067203100,
|
|
33
|
+
"meta": {},
|
|
34
|
+
"metadata": {
|
|
35
|
+
"totalInputTokens": 12,
|
|
36
|
+
"totalOutputTokens": 24,
|
|
37
|
+
"totalTokens": 36,
|
|
38
|
+
"cost": 0.000108
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "msg-204",
|
|
43
|
+
"role": "assistant",
|
|
44
|
+
"content": "Lines of logic flow,\nErrors break the peaceful code,\nTests restore the calm.",
|
|
45
|
+
"parentId": "msg-201",
|
|
46
|
+
"createdAt": 1704067203200,
|
|
47
|
+
"updatedAt": 1704067203200,
|
|
48
|
+
"meta": {},
|
|
49
|
+
"metadata": {
|
|
50
|
+
"totalInputTokens": 12,
|
|
51
|
+
"totalOutputTokens": 26,
|
|
52
|
+
"totalTokens": 38,
|
|
53
|
+
"cost": 0.000114
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "msg-205",
|
|
58
|
+
"role": "user",
|
|
59
|
+
"content": "I like the first one best!",
|
|
60
|
+
"parentId": "msg-202",
|
|
61
|
+
"createdAt": 1704067220000,
|
|
62
|
+
"updatedAt": 1704067220000,
|
|
63
|
+
"meta": {}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "msg-206",
|
|
67
|
+
"role": "assistant",
|
|
68
|
+
"content": "Thank you! I'm glad you enjoyed it. The metaphor of light revealing hidden bugs is one of my favorites. Would you like me to write more haikus on different programming topics?",
|
|
69
|
+
"parentId": "msg-205",
|
|
70
|
+
"createdAt": 1704067222000,
|
|
71
|
+
"updatedAt": 1704067222000,
|
|
72
|
+
"meta": {},
|
|
73
|
+
"metadata": {
|
|
74
|
+
"totalInputTokens": 52,
|
|
75
|
+
"totalOutputTokens": 48,
|
|
76
|
+
"totalTokens": 100,
|
|
77
|
+
"cost": 0.0003
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "msg-207",
|
|
82
|
+
"role": "user",
|
|
83
|
+
"content": "Actually, I prefer the second one with the dancing variables.",
|
|
84
|
+
"parentId": "msg-203",
|
|
85
|
+
"createdAt": 1704067225000,
|
|
86
|
+
"updatedAt": 1704067225000,
|
|
87
|
+
"meta": {}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "msg-208",
|
|
91
|
+
"role": "assistant",
|
|
92
|
+
"content": "I appreciate your feedback! The imagery of variables dancing in memory really captures the dynamic nature of programming. Would you like me to explore more haikus with that kind of vivid metaphor?",
|
|
93
|
+
"parentId": "msg-207",
|
|
94
|
+
"createdAt": 1704067227000,
|
|
95
|
+
"updatedAt": 1704067227000,
|
|
96
|
+
"meta": {},
|
|
97
|
+
"metadata": {
|
|
98
|
+
"totalInputTokens": 48,
|
|
99
|
+
"totalOutputTokens": 52,
|
|
100
|
+
"totalTokens": 100,
|
|
101
|
+
"cost": 0.0003
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "msg-209",
|
|
106
|
+
"role": "user",
|
|
107
|
+
"content": "Yes, please write one more about debugging!",
|
|
108
|
+
"parentId": "msg-206",
|
|
109
|
+
"createdAt": 1704067230000,
|
|
110
|
+
"updatedAt": 1704067230000,
|
|
111
|
+
"meta": {}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "msg-210",
|
|
115
|
+
"role": "assistant",
|
|
116
|
+
"content": "Console logs cascade,\nBreakpoints pause the racing code,\nTruth emerges clear.",
|
|
117
|
+
"parentId": "msg-209",
|
|
118
|
+
"createdAt": 1704067232000,
|
|
119
|
+
"updatedAt": 1704067232000,
|
|
120
|
+
"meta": {},
|
|
121
|
+
"metadata": {
|
|
122
|
+
"totalInputTokens": 78,
|
|
123
|
+
"totalOutputTokens": 24,
|
|
124
|
+
"totalTokens": 102,
|
|
125
|
+
"cost": 0.000306
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Message } from '../../../../types';
|
|
2
|
+
import activeIndex1 from './active-index-1.json';
|
|
3
|
+
import assistantBranch from './assistant-branch.json';
|
|
4
|
+
import assistantUserBranch from './assistant-user-branch.json';
|
|
5
|
+
import conversation from './conversation.json';
|
|
6
|
+
import nested from './nested.json';
|
|
7
|
+
|
|
8
|
+
export const branch = {
|
|
9
|
+
activeIndex1: activeIndex1 as Message[],
|
|
10
|
+
assistantBranch: assistantBranch as Message[],
|
|
11
|
+
assistantUserBranch: assistantUserBranch as Message[],
|
|
12
|
+
conversation: conversation as Message[],
|
|
13
|
+
nested: nested as Message[],
|
|
14
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-301",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "What's your favorite programming paradigm?",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "msg-302",
|
|
13
|
+
"role": "assistant",
|
|
14
|
+
"content": "I appreciate functional programming for its elegance.",
|
|
15
|
+
"parentId": "msg-301",
|
|
16
|
+
"createdAt": 1704067202000,
|
|
17
|
+
"updatedAt": 1704067202000,
|
|
18
|
+
"meta": {},
|
|
19
|
+
"metadata": {
|
|
20
|
+
"totalInputTokens": 10,
|
|
21
|
+
"totalOutputTokens": 15,
|
|
22
|
+
"totalTokens": 25,
|
|
23
|
+
"cost": 0.00008
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "msg-303",
|
|
28
|
+
"role": "assistant",
|
|
29
|
+
"content": "Object-oriented programming offers great structure.",
|
|
30
|
+
"parentId": "msg-301",
|
|
31
|
+
"createdAt": 1704067202100,
|
|
32
|
+
"updatedAt": 1704067202100,
|
|
33
|
+
"meta": {},
|
|
34
|
+
"metadata": {
|
|
35
|
+
"totalInputTokens": 10,
|
|
36
|
+
"totalOutputTokens": 12,
|
|
37
|
+
"totalTokens": 22,
|
|
38
|
+
"cost": 0.00007
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "msg-304",
|
|
43
|
+
"role": "assistant",
|
|
44
|
+
"content": "Procedural programming is straightforward and efficient.",
|
|
45
|
+
"parentId": "msg-301",
|
|
46
|
+
"createdAt": 1704067202200,
|
|
47
|
+
"updatedAt": 1704067202200,
|
|
48
|
+
"meta": {},
|
|
49
|
+
"metadata": {
|
|
50
|
+
"totalInputTokens": 10,
|
|
51
|
+
"totalOutputTokens": 13,
|
|
52
|
+
"totalTokens": 23,
|
|
53
|
+
"cost": 0.000069
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "msg-305",
|
|
58
|
+
"role": "user",
|
|
59
|
+
"content": "Can you explain more about functional programming?",
|
|
60
|
+
"parentId": "msg-302",
|
|
61
|
+
"createdAt": 1704067210000,
|
|
62
|
+
"updatedAt": 1704067210000,
|
|
63
|
+
"meta": {},
|
|
64
|
+
"metadata": {
|
|
65
|
+
"activeBranchIndex": 1
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "msg-306",
|
|
70
|
+
"role": "assistant",
|
|
71
|
+
"content": "Functional programming focuses on pure functions and immutability.",
|
|
72
|
+
"parentId": "msg-305",
|
|
73
|
+
"createdAt": 1704067212000,
|
|
74
|
+
"updatedAt": 1704067212000,
|
|
75
|
+
"meta": {},
|
|
76
|
+
"metadata": {
|
|
77
|
+
"totalInputTokens": 30,
|
|
78
|
+
"totalOutputTokens": 18,
|
|
79
|
+
"totalTokens": 48,
|
|
80
|
+
"cost": 0.00014
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "msg-307",
|
|
85
|
+
"role": "assistant",
|
|
86
|
+
"content": "In functional programming, functions are first-class citizens and side effects are minimized.",
|
|
87
|
+
"parentId": "msg-305",
|
|
88
|
+
"createdAt": 1704067212100,
|
|
89
|
+
"updatedAt": 1704067212100,
|
|
90
|
+
"meta": {},
|
|
91
|
+
"metadata": {
|
|
92
|
+
"totalInputTokens": 30,
|
|
93
|
+
"totalOutputTokens": 22,
|
|
94
|
+
"totalTokens": 52,
|
|
95
|
+
"cost": 0.00016
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "msg-310",
|
|
100
|
+
"role": "user",
|
|
101
|
+
"content": "What are some benefits of immutability?",
|
|
102
|
+
"parentId": "msg-307",
|
|
103
|
+
"createdAt": 1704067220000,
|
|
104
|
+
"updatedAt": 1704067220000,
|
|
105
|
+
"meta": {}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "msg-311",
|
|
109
|
+
"role": "assistant",
|
|
110
|
+
"content": "Immutability prevents bugs from unexpected data changes.",
|
|
111
|
+
"parentId": "msg-310",
|
|
112
|
+
"createdAt": 1704067222000,
|
|
113
|
+
"updatedAt": 1704067222000,
|
|
114
|
+
"meta": {},
|
|
115
|
+
"metadata": {
|
|
116
|
+
"totalInputTokens": 55,
|
|
117
|
+
"totalOutputTokens": 16,
|
|
118
|
+
"totalTokens": 71,
|
|
119
|
+
"cost": 0.00021
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "msg-312",
|
|
124
|
+
"role": "assistant",
|
|
125
|
+
"content": "It makes code easier to reason about and test.",
|
|
126
|
+
"parentId": "msg-310",
|
|
127
|
+
"createdAt": 1704067222100,
|
|
128
|
+
"updatedAt": 1704067222100,
|
|
129
|
+
"meta": {},
|
|
130
|
+
"metadata": {
|
|
131
|
+
"totalInputTokens": 55,
|
|
132
|
+
"totalOutputTokens": 14,
|
|
133
|
+
"totalTokens": 69,
|
|
134
|
+
"cost": 0.0002
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "msg-314",
|
|
139
|
+
"role": "user",
|
|
140
|
+
"content": "Can you give me an example?",
|
|
141
|
+
"parentId": "msg-311",
|
|
142
|
+
"createdAt": 1704067230000,
|
|
143
|
+
"updatedAt": 1704067230000,
|
|
144
|
+
"meta": {},
|
|
145
|
+
"metadata": {
|
|
146
|
+
"activeBranchIndex": 1
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "msg-315",
|
|
151
|
+
"role": "assistant",
|
|
152
|
+
"content": "Sure! In JavaScript, using `const` with arrays means you can't reassign the variable, but you can still modify the array with push/pop.",
|
|
153
|
+
"parentId": "msg-314",
|
|
154
|
+
"createdAt": 1704067232000,
|
|
155
|
+
"updatedAt": 1704067232000,
|
|
156
|
+
"meta": {},
|
|
157
|
+
"metadata": {
|
|
158
|
+
"totalInputTokens": 75,
|
|
159
|
+
"totalOutputTokens": 35,
|
|
160
|
+
"totalTokens": 110,
|
|
161
|
+
"cost": 0.00033
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"id": "msg-316",
|
|
166
|
+
"role": "assistant",
|
|
167
|
+
"content": "Here's a better example: Instead of mutating an array with push(), functional programming uses methods like concat() or the spread operator to create new arrays.",
|
|
168
|
+
"parentId": "msg-314",
|
|
169
|
+
"createdAt": 1704067232100,
|
|
170
|
+
"updatedAt": 1704067232100,
|
|
171
|
+
"meta": {},
|
|
172
|
+
"metadata": {
|
|
173
|
+
"totalInputTokens": 75,
|
|
174
|
+
"totalOutputTokens": 42,
|
|
175
|
+
"totalTokens": 117,
|
|
176
|
+
"cost": 0.00035
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "msg-601",
|
|
4
|
+
"role": "user",
|
|
5
|
+
"content": "Should I use REST or GraphQL for my API?",
|
|
6
|
+
"parentId": null,
|
|
7
|
+
"createdAt": 1704067200000,
|
|
8
|
+
"updatedAt": 1704067200000,
|
|
9
|
+
"meta": {},
|
|
10
|
+
"metadata": {
|
|
11
|
+
"compare": true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "msg-602",
|
|
16
|
+
"role": "assistant",
|
|
17
|
+
"content": "**REST is a great choice:**\n\nREST is simple, well-understood, and has excellent caching support. It's perfect for:\n\n- CRUD operations\n- Public APIs\n- Mobile apps with limited bandwidth\n- Teams familiar with HTTP conventions\n\n**Advantages:**\n- HTTP caching works out of the box\n- Stateless architecture\n- Wide tooling support\n- Easy to learn\n\n**Trade-offs:**\n- Over-fetching/under-fetching data\n- Multiple endpoints to maintain\n- Versioning can be complex",
|
|
18
|
+
"parentId": "msg-601",
|
|
19
|
+
"model": "gpt-4",
|
|
20
|
+
"provider": "openai",
|
|
21
|
+
"createdAt": 1704067205000,
|
|
22
|
+
"updatedAt": 1704067205000,
|
|
23
|
+
"meta": {},
|
|
24
|
+
"metadata": {
|
|
25
|
+
"totalInputTokens": 12,
|
|
26
|
+
"totalOutputTokens": 145,
|
|
27
|
+
"totalTokens": 157,
|
|
28
|
+
"cost": 0.00471,
|
|
29
|
+
"tps": 42.0,
|
|
30
|
+
"ttft": 387,
|
|
31
|
+
"duration": 3452,
|
|
32
|
+
"latency": 3839
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "msg-603",
|
|
37
|
+
"role": "assistant",
|
|
38
|
+
"content": "**GraphQL offers more flexibility:**\n\nGraphQL provides a powerful query language that lets clients request exactly what they need. It's ideal for:\n\n- Complex data relationships\n- Multiple client types (web, mobile, desktop)\n- Rapidly evolving requirements\n- Real-time applications\n\n**Advantages:**\n- Single endpoint\n- No over-fetching\n- Strong typing with schema\n- Powerful developer tools\n\n**Trade-offs:**\n- Steeper learning curve\n- More complex server setup\n- Caching requires extra effort\n- Can be overkill for simple APIs",
|
|
39
|
+
"parentId": "msg-601",
|
|
40
|
+
"model": "claude-3-5-sonnet-20241022",
|
|
41
|
+
"provider": "anthropic",
|
|
42
|
+
"createdAt": 1704067205100,
|
|
43
|
+
"updatedAt": 1704067205100,
|
|
44
|
+
"meta": {},
|
|
45
|
+
"metadata": {
|
|
46
|
+
"totalInputTokens": 12,
|
|
47
|
+
"totalOutputTokens": 158,
|
|
48
|
+
"totalTokens": 170,
|
|
49
|
+
"cost": 0.00085,
|
|
50
|
+
"tps": 51.0,
|
|
51
|
+
"ttft": 298,
|
|
52
|
+
"duration": 3098,
|
|
53
|
+
"latency": 3396,
|
|
54
|
+
"activeColumn": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "msg-604",
|
|
59
|
+
"role": "user",
|
|
60
|
+
"content": "What about performance differences?",
|
|
61
|
+
"parentId": "msg-603",
|
|
62
|
+
"createdAt": 1704067215000,
|
|
63
|
+
"updatedAt": 1704067215000,
|
|
64
|
+
"meta": {}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "msg-605",
|
|
68
|
+
"role": "assistant",
|
|
69
|
+
"content": "Performance-wise, both can be highly performant when implemented correctly:\n\n**REST Performance:**\n- Leverages HTTP caching (CDNs, browser cache)\n- Simpler server logic = faster response times\n- Can over-fetch data, wasting bandwidth\n\n**GraphQL Performance:**\n- Eliminates over-fetching, reducing payload size\n- Single request vs. multiple REST calls\n- Requires query complexity analysis to prevent abuse\n- DataLoader pattern helps with N+1 queries\n\n**Recommendation:** For your use case, if you're building a simple CRUD API, REST will likely perform better with less effort. If you need flexible data fetching across multiple clients, GraphQL's efficiency gains will outweigh the setup complexity.",
|
|
70
|
+
"parentId": "msg-604",
|
|
71
|
+
"createdAt": 1704067217000,
|
|
72
|
+
"updatedAt": 1704067217000,
|
|
73
|
+
"meta": {},
|
|
74
|
+
"metadata": {
|
|
75
|
+
"totalInputTokens": 182,
|
|
76
|
+
"totalOutputTokens": 167,
|
|
77
|
+
"totalTokens": 349,
|
|
78
|
+
"cost": 0.001745,
|
|
79
|
+
"tps": 48.0,
|
|
80
|
+
"ttft": 345,
|
|
81
|
+
"duration": 3479,
|
|
82
|
+
"latency": 3824
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|