@lobehub/lobehub 2.0.0-next.115 → 2.0.0-next.117

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/package.json +1 -1
  4. package/packages/context-engine/src/processors/MessageContent.ts +100 -6
  5. package/packages/context-engine/src/processors/__tests__/MessageContent.test.ts +239 -0
  6. package/packages/fetch-sse/src/fetchSSE.ts +30 -0
  7. package/packages/model-bank/src/aiModels/bedrock.ts +30 -2
  8. package/packages/model-runtime/src/const/models.ts +62 -24
  9. package/packages/model-runtime/src/core/contextBuilders/anthropic.ts +14 -0
  10. package/packages/model-runtime/src/core/contextBuilders/google.test.ts +78 -24
  11. package/packages/model-runtime/src/core/contextBuilders/google.ts +10 -2
  12. package/packages/model-runtime/src/core/parameterResolver.test.ts +34 -50
  13. package/packages/model-runtime/src/core/parameterResolver.ts +0 -41
  14. package/packages/model-runtime/src/core/streams/google/google-ai.test.ts +451 -20
  15. package/packages/model-runtime/src/core/streams/google/index.ts +113 -3
  16. package/packages/model-runtime/src/core/streams/protocol.ts +19 -0
  17. package/packages/model-runtime/src/index.ts +1 -0
  18. package/packages/model-runtime/src/providers/anthropic/index.ts +20 -32
  19. package/packages/model-runtime/src/providers/anthropic/resolveMaxTokens.ts +35 -0
  20. package/packages/model-runtime/src/providers/bedrock/index.test.ts +5 -7
  21. package/packages/model-runtime/src/providers/bedrock/index.ts +50 -11
  22. package/packages/types/src/message/common/base.ts +26 -0
  23. package/packages/types/src/message/common/metadata.ts +7 -0
  24. package/packages/utils/src/index.ts +1 -0
  25. package/packages/utils/src/multimodalContent.ts +25 -0
  26. package/src/components/Thinking/index.tsx +3 -3
  27. package/src/features/ChatList/Messages/Assistant/DisplayContent.tsx +44 -0
  28. package/src/features/ChatList/Messages/Assistant/MessageBody.tsx +96 -0
  29. package/src/features/ChatList/Messages/Assistant/Reasoning/index.tsx +26 -13
  30. package/src/features/ChatList/Messages/Assistant/index.tsx +8 -6
  31. package/src/features/ChatList/Messages/Default.tsx +4 -7
  32. package/src/features/ChatList/components/RichContentRenderer.tsx +35 -0
  33. package/src/store/agent/slices/chat/selectors/chatConfig.ts +4 -3
  34. package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +244 -17
  35. package/packages/const/src/models.ts +0 -93
  36. package/src/features/ChatList/Messages/Assistant/MessageContent.tsx +0 -78
@@ -1,78 +0,0 @@
1
- import { LOADING_FLAT } from '@lobechat/const';
2
- import { UIChatMessage } from '@lobechat/types';
3
- import { ReactNode, memo } from 'react';
4
- import { Flexbox } from 'react-layout-kit';
5
-
6
- import { useChatStore } from '@/store/chat';
7
- import { aiChatSelectors, messageStateSelectors } from '@/store/chat/selectors';
8
-
9
- import { DefaultMessage } from '../Default';
10
- import ImageFileListViewer from '../User/ImageFileListViewer';
11
- import { CollapsedMessage } from './CollapsedMessage';
12
- import FileChunks from './FileChunks';
13
- import IntentUnderstanding from './IntentUnderstanding';
14
- import Reasoning from './Reasoning';
15
- import SearchGrounding from './SearchGrounding';
16
-
17
- export const AssistantMessageContent = memo<
18
- UIChatMessage & {
19
- editableContent: ReactNode;
20
- }
21
- >(({ id, tools, content, chunksList, search, imageList, ...props }) => {
22
- const [editing, generating, isCollapsed] = useChatStore((s) => [
23
- messageStateSelectors.isMessageEditing(id)(s),
24
- messageStateSelectors.isMessageGenerating(id)(s),
25
- messageStateSelectors.isMessageCollapsed(id)(s),
26
- ]);
27
-
28
- const isToolCallGenerating = generating && (content === LOADING_FLAT || !content) && !!tools;
29
-
30
- const isReasoning = useChatStore(aiChatSelectors.isMessageInReasoning(id));
31
-
32
- const isIntentUnderstanding = useChatStore(aiChatSelectors.isIntentUnderstanding(id));
33
-
34
- const showSearch = !!search && !!search.citations?.length;
35
- const showImageItems = !!imageList && imageList.length > 0;
36
-
37
- // remove \n to avoid empty content
38
- // refs: https://github.com/lobehub/lobe-chat/pull/6153
39
- const showReasoning =
40
- (!!props.reasoning && props.reasoning.content?.trim() !== '') ||
41
- (!props.reasoning && isReasoning);
42
-
43
- const showFileChunks = !!chunksList && chunksList.length > 0;
44
-
45
- if (editing)
46
- return (
47
- <DefaultMessage
48
- content={content}
49
- id={id}
50
- isToolCallGenerating={isToolCallGenerating}
51
- {...props}
52
- />
53
- );
54
-
55
- if (isCollapsed) return <CollapsedMessage content={content} id={id} />;
56
-
57
- return (
58
- <Flexbox gap={8} id={id}>
59
- {showSearch && (
60
- <SearchGrounding citations={search?.citations} searchQueries={search?.searchQueries} />
61
- )}
62
- {showFileChunks && <FileChunks data={chunksList} />}
63
- {showReasoning && <Reasoning {...props.reasoning} id={id} />}
64
- {isIntentUnderstanding ? (
65
- <IntentUnderstanding />
66
- ) : (
67
- <DefaultMessage
68
- addIdOnDOM={false}
69
- content={content}
70
- id={id}
71
- isToolCallGenerating={isToolCallGenerating}
72
- {...props}
73
- />
74
- )}
75
- {showImageItems && <ImageFileListViewer items={imageList} />}
76
- </Flexbox>
77
- );
78
- });