@agentscope-ai/chat 1.1.39 → 1.1.41-beta.1764749089549
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/bin/starter_webui.zip +0 -0
- package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.tsx +8 -4
- package/components/ImageGenerator/index.tsx +1 -1
- package/components/Markdown/Markdown.tsx +105 -0
- package/components/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.tsx +1 -1
- package/components/Markdown/core/components/Null.tsx +1 -0
- package/components/Markdown/core/components/Raw.tsx +18 -0
- package/components/Markdown/{Markdown → core}/hooks/useCitationsData.tsx +3 -7
- package/components/Markdown/core/hooks/useCursorContent.tsx +15 -0
- package/components/Markdown/{Markdown/hooks/useTyping.ts → core/hooks/useTyping.tsx} +4 -1
- package/components/Markdown/core/index.tsx +18 -0
- package/components/Markdown/{plugins → core/plugins}/citations/CitationComponent.tsx +5 -3
- package/components/Markdown/{plugins → core/plugins}/citations/index.tsx +3 -4
- package/components/Markdown/{plugins → core/plugins}/cursor/Underline.tsx +1 -1
- package/components/Markdown/{plugins → core/plugins}/cursor/index.tsx +8 -8
- package/components/Markdown/demo/cursor.tsx +2 -3
- package/components/Markdown/index.en-US.md +1 -2
- package/components/Markdown/index.tsx +6 -0
- package/components/Markdown/index.zh-CN.md +1 -2
- package/components/Markdown/{Markdown/style.ts → styles.ts} +12 -21
- package/components/Markdown/types.tsx +94 -0
- package/components/index.ts +1 -3
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.js +5 -3
- package/lib/ImageGenerator/index.js +1 -1
- package/lib/Markdown/Markdown.d.ts +4 -0
- package/lib/Markdown/Markdown.js +110 -0
- package/lib/Markdown/core/components/Null.d.ts +2 -0
- package/lib/Markdown/core/components/Null.js +3 -0
- package/lib/Markdown/core/components/Raw.d.ts +8 -0
- package/lib/Markdown/core/components/Raw.js +13 -0
- package/lib/Markdown/core/hooks/useCitationsData.d.ts +6 -0
- package/lib/Markdown/{Markdown → core}/hooks/useCitationsData.js +1 -1
- package/lib/Markdown/core/hooks/useCursorContent.d.ts +4 -0
- package/lib/Markdown/core/hooks/useCursorContent.js +14 -0
- package/lib/Markdown/core/hooks/useTyping.d.ts +5 -0
- package/lib/Markdown/{Markdown → core}/hooks/useTyping.js +3 -2
- package/lib/Markdown/core/index.d.ts +2 -0
- package/lib/Markdown/{Markdown/hooks/useAnimation.js → core/index.js} +23 -23
- package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.js +5 -5
- package/lib/Markdown/{plugins → core/plugins}/citations/index.d.ts +1 -2
- package/lib/Markdown/{plugins → core/plugins}/citations/index.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/index.js +4 -4
- package/lib/Markdown/index.d.ts +2 -1
- package/lib/Markdown/styles.js +32 -0
- package/lib/Markdown/types.d.ts +78 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/package.json +7 -31
- package/components/AGUI/components/HelpModal/icons.tsx +0 -68
- package/components/AGUI/components/HelpModal/index.tsx +0 -1
- package/components/AGUI/components/HelpModal/modal.tsx +0 -101
- package/components/AGUI/components/chat/Button.tsx +0 -18
- package/components/AGUI/components/chat/Chat.tsx +0 -780
- package/components/AGUI/components/chat/ChatContext.tsx +0 -248
- package/components/AGUI/components/chat/CodeBlock.tsx +0 -406
- package/components/AGUI/components/chat/Header.tsx +0 -22
- package/components/AGUI/components/chat/Icons.tsx +0 -237
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +0 -77
- package/components/AGUI/components/chat/Input.tsx +0 -24
- package/components/AGUI/components/chat/Markdown.tsx +0 -134
- package/components/AGUI/components/chat/Messages.tsx +0 -259
- package/components/AGUI/components/chat/Modal.tsx +0 -133
- package/components/AGUI/components/chat/Popup.tsx +0 -57
- package/components/AGUI/components/chat/PoweredByTag.tsx +0 -29
- package/components/AGUI/components/chat/Sidebar.tsx +0 -74
- package/components/AGUI/components/chat/Suggestion.tsx +0 -132
- package/components/AGUI/components/chat/Suggestions.tsx +0 -20
- package/components/AGUI/components/chat/Textarea.tsx +0 -61
- package/components/AGUI/components/chat/Window.tsx +0 -152
- package/components/AGUI/components/chat/index.tsx +0 -11
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +0 -69
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +0 -129
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +0 -116
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +0 -64
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +0 -26
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +0 -51
- package/components/AGUI/components/chat/messages/UserMessage.tsx +0 -10
- package/components/AGUI/components/chat/props.ts +0 -186
- package/components/AGUI/components/index.ts +0 -1
- package/components/AGUI/context/index.ts +0 -1
- package/components/AGUI/hooks/index.ts +0 -1
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +0 -122
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +0 -29
- package/components/AGUI/hooks/use-dark-mode.ts +0 -10
- package/components/AGUI/hooks/use-push-to-talk.tsx +0 -166
- package/components/AGUI/index.tsx +0 -4
- package/components/AGUI/lib/utils.test.ts +0 -7
- package/components/AGUI/lib/utils.ts +0 -27
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +0 -1
- package/components/AGUI/types/suggestions.ts +0 -6
- package/components/Markdown/Markdown/AnimationNode.tsx +0 -89
- package/components/Markdown/Markdown/Markdown.tsx +0 -61
- package/components/Markdown/Markdown/core/Parser.ts +0 -52
- package/components/Markdown/Markdown/core/Renderer.ts +0 -121
- package/components/Markdown/Markdown/core/index.ts +0 -4
- package/components/Markdown/Markdown/hooks/index.ts +0 -4
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +0 -27
- package/components/Markdown/Markdown/hooks/useStreaming.ts +0 -503
- package/components/Markdown/Markdown/index.tsx +0 -198
- package/components/Markdown/Markdown/interface.ts +0 -217
- package/components/Markdown/demo/typing.tsx +0 -82
- package/components/Markdown/index.ts +0 -1
- package/components/Markdown/plugins/latex/index.ts +0 -109
- package/components/Markdown/plugins/type.ts +0 -71
- package/lib/AGUI/components/HelpModal/icons.d.ts +0 -5
- package/lib/AGUI/components/HelpModal/icons.js +0 -84
- package/lib/AGUI/components/HelpModal/index.d.ts +0 -1
- package/lib/AGUI/components/HelpModal/index.js +0 -1
- package/lib/AGUI/components/HelpModal/modal.d.ts +0 -1
- package/lib/AGUI/components/HelpModal/modal.js +0 -104
- package/lib/AGUI/components/chat/Button.d.ts +0 -2
- package/lib/AGUI/components/chat/Button.js +0 -27
- package/lib/AGUI/components/chat/Chat.d.ts +0 -242
- package/lib/AGUI/components/chat/Chat.js +0 -634
- package/lib/AGUI/components/chat/ChatContext.d.ts +0 -142
- package/lib/AGUI/components/chat/ChatContext.js +0 -75
- package/lib/AGUI/components/chat/CodeBlock.d.ts +0 -12
- package/lib/AGUI/components/chat/CodeBlock.js +0 -398
- package/lib/AGUI/components/chat/Header.d.ts +0 -2
- package/lib/AGUI/components/chat/Header.js +0 -28
- package/lib/AGUI/components/chat/Icons.d.ts +0 -16
- package/lib/AGUI/components/chat/Icons.js +0 -247
- package/lib/AGUI/components/chat/ImageUploadQueue.d.ts +0 -11
- package/lib/AGUI/components/chat/ImageUploadQueue.js +0 -65
- package/lib/AGUI/components/chat/Input.d.ts +0 -2
- package/lib/AGUI/components/chat/Input.js +0 -30
- package/lib/AGUI/components/chat/Markdown.d.ts +0 -7
- package/lib/AGUI/components/chat/Markdown.js +0 -187
- package/lib/AGUI/components/chat/Messages.d.ts +0 -7
- package/lib/AGUI/components/chat/Messages.js +0 -242
- package/lib/AGUI/components/chat/Modal.d.ts +0 -43
- package/lib/AGUI/components/chat/Modal.js +0 -113
- package/lib/AGUI/components/chat/Popup.d.ts +0 -49
- package/lib/AGUI/components/chat/Popup.js +0 -64
- package/lib/AGUI/components/chat/PoweredByTag.d.ts +0 -3
- package/lib/AGUI/components/chat/PoweredByTag.js +0 -27
- package/lib/AGUI/components/chat/Sidebar.d.ts +0 -2
- package/lib/AGUI/components/chat/Sidebar.js +0 -85
- package/lib/AGUI/components/chat/Suggestion.d.ts +0 -16
- package/lib/AGUI/components/chat/Suggestion.js +0 -146
- package/lib/AGUI/components/chat/Suggestions.d.ts +0 -2
- package/lib/AGUI/components/chat/Suggestions.js +0 -21
- package/lib/AGUI/components/chat/Textarea.d.ts +0 -11
- package/lib/AGUI/components/chat/Textarea.js +0 -60
- package/lib/AGUI/components/chat/Window.d.ts +0 -2
- package/lib/AGUI/components/chat/Window.js +0 -115
- package/lib/AGUI/components/chat/index.d.ts +0 -11
- package/lib/AGUI/components/chat/index.js +0 -11
- package/lib/AGUI/components/chat/messages/AssistantMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/AssistantMessage.js +0 -56
- package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.js +0 -114
- package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.js +0 -97
- package/lib/AGUI/components/chat/messages/RenderImageMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderImageMessage.js +0 -61
- package/lib/AGUI/components/chat/messages/RenderResultMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderResultMessage.js +0 -27
- package/lib/AGUI/components/chat/messages/RenderTextMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderTextMessage.js +0 -47
- package/lib/AGUI/components/chat/messages/UserMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/UserMessage.js +0 -9
- package/lib/AGUI/components/chat/props.d.ts +0 -157
- package/lib/AGUI/components/index.d.ts +0 -1
- package/lib/AGUI/components/index.js +0 -1
- package/lib/AGUI/context/index.d.ts +0 -1
- package/lib/AGUI/context/index.js +0 -1
- package/lib/AGUI/hooks/index.d.ts +0 -1
- package/lib/AGUI/hooks/index.js +0 -1
- package/lib/AGUI/hooks/use-copilot-chat-suggestions.d.ts +0 -87
- package/lib/AGUI/hooks/use-copilot-chat-suggestions.js +0 -95
- package/lib/AGUI/hooks/use-copy-to-clipboard.d.ts +0 -7
- package/lib/AGUI/hooks/use-copy-to-clipboard.js +0 -34
- package/lib/AGUI/hooks/use-dark-mode.d.ts +0 -1
- package/lib/AGUI/hooks/use-dark-mode.js +0 -4
- package/lib/AGUI/hooks/use-push-to-talk.d.ts +0 -16
- package/lib/AGUI/hooks/use-push-to-talk.js +0 -260
- package/lib/AGUI/index.d.ts +0 -4
- package/lib/AGUI/index.js +0 -4
- package/lib/AGUI/lib/utils.d.ts +0 -2
- package/lib/AGUI/lib/utils.js +0 -52
- package/lib/AGUI/styles.css +0 -0
- package/lib/AGUI/types/css.d.ts +0 -0
- package/lib/AGUI/types/css.js +0 -0
- package/lib/AGUI/types/index.d.ts +0 -1
- package/lib/AGUI/types/index.js +0 -1
- package/lib/AGUI/types/suggestions.d.ts +0 -6
- package/lib/AGUI/types/suggestions.js +0 -1
- package/lib/Markdown/Markdown/AnimationNode.d.ts +0 -20
- package/lib/Markdown/Markdown/AnimationNode.js +0 -84
- package/lib/Markdown/Markdown/Markdown.d.ts +0 -4
- package/lib/Markdown/Markdown/Markdown.js +0 -58
- package/lib/Markdown/Markdown/core/Parser.d.ts +0 -16
- package/lib/Markdown/Markdown/core/Parser.js +0 -65
- package/lib/Markdown/Markdown/core/Renderer.d.ts +0 -24
- package/lib/Markdown/Markdown/core/Renderer.js +0 -137
- package/lib/Markdown/Markdown/core/index.d.ts +0 -3
- package/lib/Markdown/Markdown/core/index.js +0 -3
- package/lib/Markdown/Markdown/hooks/index.d.ts +0 -3
- package/lib/Markdown/Markdown/hooks/index.js +0 -3
- package/lib/Markdown/Markdown/hooks/useAnimation.d.ts +0 -4
- package/lib/Markdown/Markdown/hooks/useCitationsData.d.ts +0 -7
- package/lib/Markdown/Markdown/hooks/useStreaming.d.ts +0 -3
- package/lib/Markdown/Markdown/hooks/useStreaming.js +0 -521
- package/lib/Markdown/Markdown/hooks/useTyping.d.ts +0 -4
- package/lib/Markdown/Markdown/index.d.ts +0 -84
- package/lib/Markdown/Markdown/index.js +0 -161
- package/lib/Markdown/Markdown/interface.d.ts +0 -203
- package/lib/Markdown/Markdown/interface.js +0 -1
- package/lib/Markdown/Markdown/style.js +0 -32
- package/lib/Markdown/plugins/latex/index.d.ts +0 -9
- package/lib/Markdown/plugins/latex/index.js +0 -97
- package/lib/Markdown/plugins/type.d.ts +0 -60
- package/lib/Markdown/plugins/type.js +0 -1
- /package/components/Markdown/{Markdown/defaultComponents/DisabledImage.tsx → core/components/DisableImage.tsx} +0 -0
- /package/components/Markdown/{Markdown/defaultComponents → core/components}/Media.tsx +0 -0
- /package/components/Markdown/{plugins → core/plugins}/cursor/Dot.tsx +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.d.ts +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.js +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.d.ts → core/components/DisableImage.d.ts} +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.js → core/components/DisableImage.js} +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.d.ts +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.js +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/index.d.ts +0 -0
- /package/lib/Markdown/{Markdown/style.d.ts → styles.d.ts} +0 -0
- /package/lib/{AGUI/components/chat/props.js → Markdown/types.js} +0 -0
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from "react";
|
|
2
|
-
import * as DefaultIcons from "./Icons";
|
|
3
|
-
import { ThumbsDownIcon, ThumbsUpIcon } from "./Icons";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Icons for CopilotChat component.
|
|
7
|
-
*/
|
|
8
|
-
export interface CopilotChatIcons {
|
|
9
|
-
/**
|
|
10
|
-
* The icon to use for the open chat button.
|
|
11
|
-
* @default <OpenIcon />
|
|
12
|
-
*/
|
|
13
|
-
openIcon?: React.ReactNode;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The icon to use for the close chat button.
|
|
17
|
-
* @default <CloseIcon />
|
|
18
|
-
*/
|
|
19
|
-
closeIcon?: React.ReactNode;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The icon to use for the close chat button in the header.
|
|
23
|
-
* @default <HeaderCloseIcon />
|
|
24
|
-
*/
|
|
25
|
-
headerCloseIcon?: React.ReactNode;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The icon to use for the send button.
|
|
29
|
-
* @default <SendIcon />
|
|
30
|
-
*/
|
|
31
|
-
sendIcon?: React.ReactNode;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The icon to use for the activity indicator.
|
|
35
|
-
* @default <ActivityIcon />
|
|
36
|
-
*/
|
|
37
|
-
activityIcon?: React.ReactNode;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The icon to use for the spinner.
|
|
41
|
-
* @default <SpinnerIcon />
|
|
42
|
-
*/
|
|
43
|
-
spinnerIcon?: React.ReactNode;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The icon to use for the stop button.
|
|
47
|
-
* @default <StopIcon />
|
|
48
|
-
*/
|
|
49
|
-
stopIcon?: React.ReactNode;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The icon to use for the regenerate button.
|
|
53
|
-
* @default <RegenerateIcon />
|
|
54
|
-
*/
|
|
55
|
-
regenerateIcon?: React.ReactNode;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The icons to use for push to talk.
|
|
59
|
-
* @default <PushToTalkIcon />
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
pushToTalkIcon?: React.ReactNode;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The icons to use for copy assistant response
|
|
66
|
-
* @default <CopyIcon />
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
copyIcon?: React.ReactNode;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The icon to use for thumbs up/response approval.
|
|
73
|
-
* @default <ThumbsUpIcon />
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
thumbsUpIcon?: React.ReactNode;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The icon to use for thumbs down/response rejection.
|
|
80
|
-
* @default <ThumbsDownIcon />
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
thumbsDownIcon?: React.ReactNode;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The icon to use for the upload button.
|
|
87
|
-
* @default <UploadIcon />
|
|
88
|
-
*/
|
|
89
|
-
uploadIcon?: React.ReactNode;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Labels for CopilotChat component.
|
|
94
|
-
*/
|
|
95
|
-
export interface CopilotChatLabels {
|
|
96
|
-
/**
|
|
97
|
-
* The initial message(s) to display in the chat window.
|
|
98
|
-
*/
|
|
99
|
-
initial?: string | string[];
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The title to display in the header.
|
|
103
|
-
* @default "CopilotKit"
|
|
104
|
-
*/
|
|
105
|
-
title?: string;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* The placeholder to display in the input.
|
|
109
|
-
* @default "Type a message..."
|
|
110
|
-
*/
|
|
111
|
-
placeholder?: string;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The message to display when an error occurs.
|
|
115
|
-
* @default "❌ An error occurred. Please try again."
|
|
116
|
-
*/
|
|
117
|
-
error?: string;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The label to display on the stop button.
|
|
121
|
-
* @default "Stop generating"
|
|
122
|
-
*/
|
|
123
|
-
stopGenerating?: string;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* The label to display on the regenerate button.
|
|
127
|
-
* @default "Regenerate response"
|
|
128
|
-
*/
|
|
129
|
-
regenerateResponse?: string;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The label for the copy button.
|
|
133
|
-
* @default "Copy to clipboard"
|
|
134
|
-
*/
|
|
135
|
-
copyToClipboard?: string;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The label for the thumbs up button.
|
|
139
|
-
* @default "Thumbs up"
|
|
140
|
-
*/
|
|
141
|
-
thumbsUp?: string;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* The label for the thumbs down button.
|
|
145
|
-
* @default "Thumbs down"
|
|
146
|
-
*/
|
|
147
|
-
thumbsDown?: string;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The text to display when content is copied.
|
|
151
|
-
* @default "Copied!"
|
|
152
|
-
*/
|
|
153
|
-
copied?: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
interface ChatContext {
|
|
157
|
-
labels: Required<CopilotChatLabels>;
|
|
158
|
-
icons: Required<CopilotChatIcons>;
|
|
159
|
-
open: boolean;
|
|
160
|
-
setOpen: (open: boolean) => void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export const ChatContext = React.createContext<ChatContext | undefined>(undefined);
|
|
164
|
-
|
|
165
|
-
export function useChatContext(): ChatContext {
|
|
166
|
-
const context = React.useContext(ChatContext);
|
|
167
|
-
if (context === undefined) {
|
|
168
|
-
throw new Error(
|
|
169
|
-
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?",
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
return context;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
interface ChatContextProps {
|
|
176
|
-
// temperature?: number;
|
|
177
|
-
// instructions?: string;
|
|
178
|
-
// maxFeedback?: number;
|
|
179
|
-
labels?: CopilotChatLabels;
|
|
180
|
-
icons?: CopilotChatIcons;
|
|
181
|
-
children?: React.ReactNode;
|
|
182
|
-
open: boolean;
|
|
183
|
-
setOpen: (open: boolean) => void;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export const ChatContextProvider = ({
|
|
187
|
-
// temperature,
|
|
188
|
-
// instructions,
|
|
189
|
-
// maxFeedback,
|
|
190
|
-
labels,
|
|
191
|
-
icons,
|
|
192
|
-
children,
|
|
193
|
-
open,
|
|
194
|
-
setOpen,
|
|
195
|
-
}: ChatContextProps) => {
|
|
196
|
-
const memoizedLabels = useMemo(
|
|
197
|
-
() => ({
|
|
198
|
-
...{
|
|
199
|
-
initial: "",
|
|
200
|
-
title: "CopilotKit",
|
|
201
|
-
placeholder: "Type a message...",
|
|
202
|
-
error: "❌ An error occurred. Please try again.",
|
|
203
|
-
stopGenerating: "Stop generating",
|
|
204
|
-
regenerateResponse: "Regenerate response",
|
|
205
|
-
copyToClipboard: "Copy to clipboard",
|
|
206
|
-
thumbsUp: "Thumbs up",
|
|
207
|
-
thumbsDown: "Thumbs down",
|
|
208
|
-
copied: "Copied!",
|
|
209
|
-
},
|
|
210
|
-
...labels,
|
|
211
|
-
}),
|
|
212
|
-
[labels],
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const memoizedIcons = useMemo(
|
|
216
|
-
() => ({
|
|
217
|
-
...{
|
|
218
|
-
openIcon: DefaultIcons.OpenIcon,
|
|
219
|
-
closeIcon: DefaultIcons.CloseIcon,
|
|
220
|
-
headerCloseIcon: DefaultIcons.HeaderCloseIcon,
|
|
221
|
-
sendIcon: DefaultIcons.SendIcon,
|
|
222
|
-
activityIcon: DefaultIcons.ActivityIcon,
|
|
223
|
-
spinnerIcon: DefaultIcons.SpinnerIcon,
|
|
224
|
-
stopIcon: DefaultIcons.StopIcon,
|
|
225
|
-
regenerateIcon: DefaultIcons.RegenerateIcon,
|
|
226
|
-
pushToTalkIcon: DefaultIcons.MicrophoneIcon,
|
|
227
|
-
copyIcon: DefaultIcons.CopyIcon,
|
|
228
|
-
thumbsUpIcon: DefaultIcons.ThumbsUpIcon,
|
|
229
|
-
thumbsDownIcon: DefaultIcons.ThumbsDownIcon,
|
|
230
|
-
uploadIcon: DefaultIcons.UploadIcon,
|
|
231
|
-
},
|
|
232
|
-
...icons,
|
|
233
|
-
}),
|
|
234
|
-
[icons],
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
const context = useMemo(
|
|
238
|
-
() => ({
|
|
239
|
-
labels: memoizedLabels,
|
|
240
|
-
icons: memoizedIcons,
|
|
241
|
-
open,
|
|
242
|
-
setOpen,
|
|
243
|
-
}),
|
|
244
|
-
[memoizedLabels, memoizedIcons, open, setOpen],
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;
|
|
248
|
-
};
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
import { FC, memo } from "react";
|
|
2
|
-
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
3
|
-
import { useCopyToClipboard } from "../../hooks/use-copy-to-clipboard";
|
|
4
|
-
import { CheckIcon, CopyIcon, DownloadIcon } from "./Icons";
|
|
5
|
-
|
|
6
|
-
interface CodeActionButtonProps {
|
|
7
|
-
onClick: () => void;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
language: string;
|
|
13
|
-
value: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface languageMap {
|
|
17
|
-
[key: string]: string | undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const programmingLanguages: languageMap = {
|
|
21
|
-
javascript: ".js",
|
|
22
|
-
python: ".py",
|
|
23
|
-
java: ".java",
|
|
24
|
-
c: ".c",
|
|
25
|
-
cpp: ".cpp",
|
|
26
|
-
"c++": ".cpp",
|
|
27
|
-
"c#": ".cs",
|
|
28
|
-
ruby: ".rb",
|
|
29
|
-
php: ".php",
|
|
30
|
-
swift: ".swift",
|
|
31
|
-
"objective-c": ".m",
|
|
32
|
-
kotlin: ".kt",
|
|
33
|
-
typescript: ".ts",
|
|
34
|
-
go: ".go",
|
|
35
|
-
perl: ".pl",
|
|
36
|
-
rust: ".rs",
|
|
37
|
-
scala: ".scala",
|
|
38
|
-
haskell: ".hs",
|
|
39
|
-
lua: ".lua",
|
|
40
|
-
shell: ".sh",
|
|
41
|
-
sql: ".sql",
|
|
42
|
-
html: ".html",
|
|
43
|
-
css: ".css",
|
|
44
|
-
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const generateRandomString = (length: number, lowercase = false) => {
|
|
48
|
-
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789"; // excluding similar looking characters like Z, 2, I, 1, O, 0
|
|
49
|
-
let result = "";
|
|
50
|
-
for (let i = 0; i < length; i++) {
|
|
51
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
52
|
-
}
|
|
53
|
-
return lowercase ? result.toLowerCase() : result;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
57
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
|
|
58
|
-
|
|
59
|
-
const downloadAsFile = () => {
|
|
60
|
-
if (typeof window === "undefined") {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const fileExtension = programmingLanguages[language] || ".file";
|
|
64
|
-
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
65
|
-
const fileName = window.prompt("Enter file name" || "", suggestedFileName);
|
|
66
|
-
|
|
67
|
-
if (!fileName) {
|
|
68
|
-
// User pressed cancel on prompt.
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const blob = new Blob([value], { type: "text/plain" });
|
|
73
|
-
const url = URL.createObjectURL(blob);
|
|
74
|
-
const link = document.createElement("a");
|
|
75
|
-
link.download = fileName;
|
|
76
|
-
link.href = url;
|
|
77
|
-
link.style.display = "none";
|
|
78
|
-
document.body.appendChild(link);
|
|
79
|
-
link.click();
|
|
80
|
-
document.body.removeChild(link);
|
|
81
|
-
URL.revokeObjectURL(url);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const onCopy = () => {
|
|
85
|
-
if (isCopied) return;
|
|
86
|
-
copyToClipboard(value);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<div className="copilotKitCodeBlock">
|
|
91
|
-
<div className="copilotKitCodeBlockToolbar">
|
|
92
|
-
<span className="copilotKitCodeBlockToolbarLanguage">{language}</span>
|
|
93
|
-
<div className="copilotKitCodeBlockToolbarButtons">
|
|
94
|
-
<button className="copilotKitCodeBlockToolbarButton" onClick={downloadAsFile}>
|
|
95
|
-
{DownloadIcon}
|
|
96
|
-
</button>
|
|
97
|
-
<button className="copilotKitCodeBlockToolbarButton" onClick={onCopy}>
|
|
98
|
-
{isCopied ? CheckIcon : CopyIcon}
|
|
99
|
-
</button>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
<SyntaxHighlighter
|
|
103
|
-
language={language}
|
|
104
|
-
style={highlightStyle}
|
|
105
|
-
PreTag="div"
|
|
106
|
-
customStyle={{
|
|
107
|
-
margin: 0,
|
|
108
|
-
borderBottomLeftRadius: "0.375rem",
|
|
109
|
-
borderBottomRightRadius: "0.375rem",
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
{value}
|
|
113
|
-
</SyntaxHighlighter>
|
|
114
|
-
</div>
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
CodeBlock.displayName = "CodeBlock";
|
|
118
|
-
|
|
119
|
-
export { CodeBlock };
|
|
120
|
-
|
|
121
|
-
// import { vscDarkPlus as highlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
122
|
-
// As a workaround, we inline the vscDarkPlus from react-syntax-highlighter.
|
|
123
|
-
// Importing it as recommended in the documentation leads to build errors in the non app router
|
|
124
|
-
// (Next.js classic) setup.
|
|
125
|
-
const highlightStyle: any = {
|
|
126
|
-
'pre[class*="language-"]': {
|
|
127
|
-
color: "#d4d4d4",
|
|
128
|
-
fontSize: "13px",
|
|
129
|
-
textShadow: "none",
|
|
130
|
-
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
131
|
-
direction: "ltr",
|
|
132
|
-
textAlign: "left",
|
|
133
|
-
whiteSpace: "pre",
|
|
134
|
-
wordSpacing: "normal",
|
|
135
|
-
wordBreak: "normal",
|
|
136
|
-
lineHeight: "1.5",
|
|
137
|
-
MozTabSize: "4",
|
|
138
|
-
OTabSize: "4",
|
|
139
|
-
tabSize: "4",
|
|
140
|
-
WebkitHyphens: "none",
|
|
141
|
-
MozHyphens: "none",
|
|
142
|
-
msHyphens: "none",
|
|
143
|
-
hyphens: "none",
|
|
144
|
-
padding: "1em",
|
|
145
|
-
margin: ".5em 0",
|
|
146
|
-
overflow: "auto",
|
|
147
|
-
background: "#1e1e1e",
|
|
148
|
-
},
|
|
149
|
-
'code[class*="language-"]': {
|
|
150
|
-
color: "#d4d4d4",
|
|
151
|
-
fontSize: "13px",
|
|
152
|
-
textShadow: "none",
|
|
153
|
-
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
154
|
-
direction: "ltr",
|
|
155
|
-
textAlign: "left",
|
|
156
|
-
whiteSpace: "pre",
|
|
157
|
-
wordSpacing: "normal",
|
|
158
|
-
wordBreak: "normal",
|
|
159
|
-
lineHeight: "1.5",
|
|
160
|
-
MozTabSize: "4",
|
|
161
|
-
OTabSize: "4",
|
|
162
|
-
tabSize: "4",
|
|
163
|
-
WebkitHyphens: "none",
|
|
164
|
-
MozHyphens: "none",
|
|
165
|
-
msHyphens: "none",
|
|
166
|
-
hyphens: "none",
|
|
167
|
-
},
|
|
168
|
-
'pre[class*="language-"]::selection': {
|
|
169
|
-
textShadow: "none",
|
|
170
|
-
background: "#264F78",
|
|
171
|
-
},
|
|
172
|
-
'code[class*="language-"]::selection': {
|
|
173
|
-
textShadow: "none",
|
|
174
|
-
background: "#264F78",
|
|
175
|
-
},
|
|
176
|
-
'pre[class*="language-"] *::selection': {
|
|
177
|
-
textShadow: "none",
|
|
178
|
-
background: "#264F78",
|
|
179
|
-
},
|
|
180
|
-
'code[class*="language-"] *::selection': {
|
|
181
|
-
textShadow: "none",
|
|
182
|
-
background: "#264F78",
|
|
183
|
-
},
|
|
184
|
-
':not(pre) > code[class*="language-"]': {
|
|
185
|
-
padding: ".1em .3em",
|
|
186
|
-
borderRadius: ".3em",
|
|
187
|
-
color: "#db4c69",
|
|
188
|
-
background: "#1e1e1e",
|
|
189
|
-
},
|
|
190
|
-
".namespace": {
|
|
191
|
-
Opacity: ".7",
|
|
192
|
-
},
|
|
193
|
-
"doctype.doctype-tag": {
|
|
194
|
-
color: "#569CD6",
|
|
195
|
-
},
|
|
196
|
-
"doctype.name": {
|
|
197
|
-
color: "#9cdcfe",
|
|
198
|
-
},
|
|
199
|
-
comment: {
|
|
200
|
-
color: "#6a9955",
|
|
201
|
-
},
|
|
202
|
-
prolog: {
|
|
203
|
-
color: "#6a9955",
|
|
204
|
-
},
|
|
205
|
-
punctuation: {
|
|
206
|
-
color: "#d4d4d4",
|
|
207
|
-
},
|
|
208
|
-
".language-html .language-css .token.punctuation": {
|
|
209
|
-
color: "#d4d4d4",
|
|
210
|
-
},
|
|
211
|
-
".language-html .language-javascript .token.punctuation": {
|
|
212
|
-
color: "#d4d4d4",
|
|
213
|
-
},
|
|
214
|
-
property: {
|
|
215
|
-
color: "#9cdcfe",
|
|
216
|
-
},
|
|
217
|
-
tag: {
|
|
218
|
-
color: "#569cd6",
|
|
219
|
-
},
|
|
220
|
-
boolean: {
|
|
221
|
-
color: "#569cd6",
|
|
222
|
-
},
|
|
223
|
-
number: {
|
|
224
|
-
color: "#b5cea8",
|
|
225
|
-
},
|
|
226
|
-
constant: {
|
|
227
|
-
color: "#9cdcfe",
|
|
228
|
-
},
|
|
229
|
-
symbol: {
|
|
230
|
-
color: "#b5cea8",
|
|
231
|
-
},
|
|
232
|
-
inserted: {
|
|
233
|
-
color: "#b5cea8",
|
|
234
|
-
},
|
|
235
|
-
unit: {
|
|
236
|
-
color: "#b5cea8",
|
|
237
|
-
},
|
|
238
|
-
selector: {
|
|
239
|
-
color: "#d7ba7d",
|
|
240
|
-
},
|
|
241
|
-
"attr-name": {
|
|
242
|
-
color: "#9cdcfe",
|
|
243
|
-
},
|
|
244
|
-
string: {
|
|
245
|
-
color: "#ce9178",
|
|
246
|
-
},
|
|
247
|
-
char: {
|
|
248
|
-
color: "#ce9178",
|
|
249
|
-
},
|
|
250
|
-
builtin: {
|
|
251
|
-
color: "#ce9178",
|
|
252
|
-
},
|
|
253
|
-
deleted: {
|
|
254
|
-
color: "#ce9178",
|
|
255
|
-
},
|
|
256
|
-
".language-css .token.string.url": {
|
|
257
|
-
textDecoration: "underline",
|
|
258
|
-
},
|
|
259
|
-
operator: {
|
|
260
|
-
color: "#d4d4d4",
|
|
261
|
-
},
|
|
262
|
-
entity: {
|
|
263
|
-
color: "#569cd6",
|
|
264
|
-
},
|
|
265
|
-
"operator.arrow": {
|
|
266
|
-
color: "#569CD6",
|
|
267
|
-
},
|
|
268
|
-
atrule: {
|
|
269
|
-
color: "#ce9178",
|
|
270
|
-
},
|
|
271
|
-
"atrule.rule": {
|
|
272
|
-
color: "#c586c0",
|
|
273
|
-
},
|
|
274
|
-
"atrule.url": {
|
|
275
|
-
color: "#9cdcfe",
|
|
276
|
-
},
|
|
277
|
-
"atrule.url.function": {
|
|
278
|
-
color: "#dcdcaa",
|
|
279
|
-
},
|
|
280
|
-
"atrule.url.punctuation": {
|
|
281
|
-
color: "#d4d4d4",
|
|
282
|
-
},
|
|
283
|
-
keyword: {
|
|
284
|
-
color: "#569CD6",
|
|
285
|
-
},
|
|
286
|
-
"keyword.module": {
|
|
287
|
-
color: "#c586c0",
|
|
288
|
-
},
|
|
289
|
-
"keyword.control-flow": {
|
|
290
|
-
color: "#c586c0",
|
|
291
|
-
},
|
|
292
|
-
function: {
|
|
293
|
-
color: "#dcdcaa",
|
|
294
|
-
},
|
|
295
|
-
"function.maybe-class-name": {
|
|
296
|
-
color: "#dcdcaa",
|
|
297
|
-
},
|
|
298
|
-
regex: {
|
|
299
|
-
color: "#d16969",
|
|
300
|
-
},
|
|
301
|
-
important: {
|
|
302
|
-
color: "#569cd6",
|
|
303
|
-
},
|
|
304
|
-
italic: {
|
|
305
|
-
fontStyle: "italic",
|
|
306
|
-
},
|
|
307
|
-
"class-name": {
|
|
308
|
-
color: "#4ec9b0",
|
|
309
|
-
},
|
|
310
|
-
"maybe-class-name": {
|
|
311
|
-
color: "#4ec9b0",
|
|
312
|
-
},
|
|
313
|
-
console: {
|
|
314
|
-
color: "#9cdcfe",
|
|
315
|
-
},
|
|
316
|
-
parameter: {
|
|
317
|
-
color: "#9cdcfe",
|
|
318
|
-
},
|
|
319
|
-
interpolation: {
|
|
320
|
-
color: "#9cdcfe",
|
|
321
|
-
},
|
|
322
|
-
"punctuation.interpolation-punctuation": {
|
|
323
|
-
color: "#569cd6",
|
|
324
|
-
},
|
|
325
|
-
variable: {
|
|
326
|
-
color: "#9cdcfe",
|
|
327
|
-
},
|
|
328
|
-
"imports.maybe-class-name": {
|
|
329
|
-
color: "#9cdcfe",
|
|
330
|
-
},
|
|
331
|
-
"exports.maybe-class-name": {
|
|
332
|
-
color: "#9cdcfe",
|
|
333
|
-
},
|
|
334
|
-
escape: {
|
|
335
|
-
color: "#d7ba7d",
|
|
336
|
-
},
|
|
337
|
-
"tag.punctuation": {
|
|
338
|
-
color: "#808080",
|
|
339
|
-
},
|
|
340
|
-
cdata: {
|
|
341
|
-
color: "#808080",
|
|
342
|
-
},
|
|
343
|
-
"attr-value": {
|
|
344
|
-
color: "#ce9178",
|
|
345
|
-
},
|
|
346
|
-
"attr-value.punctuation": {
|
|
347
|
-
color: "#ce9178",
|
|
348
|
-
},
|
|
349
|
-
"attr-value.punctuation.attr-equals": {
|
|
350
|
-
color: "#d4d4d4",
|
|
351
|
-
},
|
|
352
|
-
namespace: {
|
|
353
|
-
color: "#4ec9b0",
|
|
354
|
-
},
|
|
355
|
-
'pre[class*="language-javascript"]': {
|
|
356
|
-
color: "#9cdcfe",
|
|
357
|
-
},
|
|
358
|
-
'code[class*="language-javascript"]': {
|
|
359
|
-
color: "#9cdcfe",
|
|
360
|
-
},
|
|
361
|
-
'pre[class*="language-jsx"]': {
|
|
362
|
-
color: "#9cdcfe",
|
|
363
|
-
},
|
|
364
|
-
'code[class*="language-jsx"]': {
|
|
365
|
-
color: "#9cdcfe",
|
|
366
|
-
},
|
|
367
|
-
'pre[class*="language-typescript"]': {
|
|
368
|
-
color: "#9cdcfe",
|
|
369
|
-
},
|
|
370
|
-
'code[class*="language-typescript"]': {
|
|
371
|
-
color: "#9cdcfe",
|
|
372
|
-
},
|
|
373
|
-
'pre[class*="language-tsx"]': {
|
|
374
|
-
color: "#9cdcfe",
|
|
375
|
-
},
|
|
376
|
-
'code[class*="language-tsx"]': {
|
|
377
|
-
color: "#9cdcfe",
|
|
378
|
-
},
|
|
379
|
-
'pre[class*="language-css"]': {
|
|
380
|
-
color: "#ce9178",
|
|
381
|
-
},
|
|
382
|
-
'code[class*="language-css"]': {
|
|
383
|
-
color: "#ce9178",
|
|
384
|
-
},
|
|
385
|
-
'pre[class*="language-html"]': {
|
|
386
|
-
color: "#d4d4d4",
|
|
387
|
-
},
|
|
388
|
-
'code[class*="language-html"]': {
|
|
389
|
-
color: "#d4d4d4",
|
|
390
|
-
},
|
|
391
|
-
".language-regex .token.anchor": {
|
|
392
|
-
color: "#dcdcaa",
|
|
393
|
-
},
|
|
394
|
-
".language-html .token.punctuation": {
|
|
395
|
-
color: "#808080",
|
|
396
|
-
},
|
|
397
|
-
'pre[class*="language-"] > code[class*="language-"]': {
|
|
398
|
-
position: "relative",
|
|
399
|
-
zIndex: "1",
|
|
400
|
-
},
|
|
401
|
-
".line-highlight.line-highlight": {
|
|
402
|
-
background: "#f7ebc6",
|
|
403
|
-
boxShadow: "inset 5px 0 0 #f7d87c",
|
|
404
|
-
zIndex: "0",
|
|
405
|
-
},
|
|
406
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HeaderProps } from "./props";
|
|
2
|
-
import { useChatContext } from "./ChatContext";
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
|
-
export const Header = ({}: HeaderProps) => {
|
|
6
|
-
const { setOpen, icons, labels } = useChatContext();
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="copilotKitHeader">
|
|
10
|
-
<div>{labels.title}</div>
|
|
11
|
-
<div className="copilotKitHeaderControls">
|
|
12
|
-
<button
|
|
13
|
-
onClick={() => setOpen(false)}
|
|
14
|
-
aria-label="Close"
|
|
15
|
-
className="copilotKitHeaderCloseButton"
|
|
16
|
-
>
|
|
17
|
-
{icons.headerCloseIcon}
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
};
|