@@ -4,15 +4,12 @@ import {
4
4
ComposerPrimitive ,
5
5
MessagePrimitive ,
6
6
ThreadPrimitive ,
7
- useComposerStore ,
8
7
useMessage ,
9
- useMessageStore ,
10
8
useThreadRuntime ,
11
9
} from "@assistant-ui/react" ;
12
10
import { type FC } from "react" ;
13
11
import NextImage from "next/image" ;
14
12
15
- import { Button } from "./ui/button" ;
16
13
import { ArrowDownIcon , SendHorizontalIcon } from "lucide-react" ;
17
14
import { MarkdownText } from "./ui/assistant-ui/markdown-text" ;
18
15
import { TooltipIconButton } from "./ui/assistant-ui/tooltip-icon-button" ;
@@ -47,15 +44,14 @@ export const MyThread: FC<MyThreadProps> = (props: MyThreadProps) => {
47
44
< ThreadPrimitive . Messages
48
45
components = { {
49
46
UserMessage : MyUserMessage ,
50
- EditComposer : MyEditComposer ,
51
47
AssistantMessage : MyAssistantMessage ,
52
48
} }
53
49
/>
54
50
</ ThreadPrimitive . Viewport >
55
51
< MyThreadScrollToBottom />
56
52
{ isEmpty ? (
57
- < div className = "absolute left-1/2 transform -translate-x-1/2 max-w-2xl top-1/2 -translate-y-1/2 " >
58
- < div className = "flex flex-row gap-1 items-center justify-center mb-[50px ]" >
53
+ < div className = "absolute left-1/2 transform -translate-x-1/2 max-w-2xl top-1/2 -translate-y-[70%] " >
54
+ < div className = "flex flex-row gap-1 items-center justify-center mb-[24px ]" >
59
55
< p className = "text-2xl" > Chat LangChain</ p >
60
56
< NextImage
61
57
src = "/images/lc_logo.jpg"
@@ -65,7 +61,7 @@ export const MyThread: FC<MyThreadProps> = (props: MyThreadProps) => {
65
61
height = { 40 }
66
62
/>
67
63
</ div >
68
- < div className = "mb-[350px ] ml-[30px]" >
64
+ < div className = "mb-[110px ] ml-[30px]" >
69
65
< SuggestedQuestions />
70
66
</ div >
71
67
< MyComposer messages = { props . messages } />
@@ -102,8 +98,8 @@ const MyComposer: FC<MyComposerProps> = (props: MyComposerProps) => {
102
98
< ComposerPrimitive . Root
103
99
className = { cn (
104
100
"focus-within:border-aui-ring/20 flex w-full items-center rounded-lg border px-2.5 py-2.5 shadow-sm transition-all duration-300 ease-in-out bg-[#282828] border-gray-600" ,
105
- "absolute left-1/2 transform -translate-x-1/2 max-w-2xl " ,
106
- isEmpty ? "top-1/2 -translate-y -1/2" : "bottom-4 " ,
101
+ "absolute transform bottom-4 " ,
102
+ ! isEmpty ? "left-[43%] -translate-x -1/2 max-w-3xl " : "" ,
107
103
) }
108
104
>
109
105
< ComposerPrimitive . Input
@@ -142,53 +138,14 @@ const MyComposer: FC<MyComposerProps> = (props: MyComposerProps) => {
142
138
143
139
const MyUserMessage : FC = ( ) => {
144
140
return (
145
- < MessagePrimitive . Root className = "w-full max-w-2xl pt-4 mx-auto" >
146
- < div className = "bg-inherit text-white max-w-xl break-words rounded-3xl px-5 pt-2.5 mb-[-25px] text-4xl font-light" >
141
+ < MessagePrimitive . Root className = "w-full max-w-5xl pt-4 mx-auto" >
142
+ < div className = "bg-inherit text-white max-w-3xl break-words rounded-3xl px-5 pt-2.5 mb-[-25px] text-4xl font-light" >
147
143
< MessagePrimitive . Content />
148
144
</ div >
149
145
</ MessagePrimitive . Root >
150
146
) ;
151
147
} ;
152
148
153
- const MyComposerSend = ( ) => {
154
- const messageStore = useMessageStore ( ) ;
155
- const composerStore = useComposerStore ( ) ;
156
- const threadRuntime = useThreadRuntime ( ) ;
157
-
158
- const handleSend = ( ) => {
159
- const composerState = composerStore . getState ( ) ;
160
- const { parentId, message } = messageStore . getState ( ) ;
161
-
162
- threadRuntime . append ( {
163
- parentId,
164
- role : message . role ,
165
- content : [ { type : "text" , text : composerState . text } ] ,
166
- } ) ;
167
- composerState . cancel ( ) ;
168
- } ;
169
-
170
- return < Button onClick = { handleSend } > Save</ Button > ;
171
- } ;
172
-
173
- const MyEditComposer : FC = ( ) => {
174
- return (
175
- < ComposerPrimitive . Root className = "bg-muted my-4 flex w-full max-w-2xl flex-col gap-2 rounded-xl" >
176
- < ComposerPrimitive . Input
177
- className = "text-foreground flex h-8 w-full resize-none border-none bg-transparent p-4 pb-0 outline-none focus:ring-0"
178
- // Don't submit on `Enter`, instead add a newline.
179
- submitOnEnter = { false }
180
- />
181
-
182
- < div className = "mx-3 mb-3 flex items-center justify-center gap-2 self-end" >
183
- < ComposerPrimitive . Cancel asChild >
184
- < Button variant = "ghost" > Cancel</ Button >
185
- </ ComposerPrimitive . Cancel >
186
- < MyComposerSend />
187
- </ div >
188
- </ ComposerPrimitive . Root >
189
- ) ;
190
- } ;
191
-
192
149
const MyAssistantMessage : FC = ( ) => {
193
150
const threadRuntime = useThreadRuntime ( ) ;
194
151
const threadState = threadRuntime . getState ( ) ;
@@ -198,8 +155,8 @@ const MyAssistantMessage: FC = () => {
198
155
! isLast ;
199
156
200
157
return (
201
- < MessagePrimitive . Root className = "relative flex w-full max-w-2xl py-4 mx-auto" >
202
- < div className = "ml-6 bg-inherit text-white max-w-xl break-words leading-7" >
158
+ < MessagePrimitive . Root className = "relative flex w-full max-w-5xl py-4 mx-auto" >
159
+ < div className = "ml-6 bg-inherit text-white max-w-3xl break-words leading-7" >
203
160
< MessagePrimitive . Content components = { { Text : MarkdownText } } />
204
161
{ shouldRenderMessageBreak ? (
205
162
< hr className = "relative left-1/2 -translate-x-[37.25%] w-[45vw] mt-6 border-gray-600" />
0 commit comments