-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27b3a54
commit 379de08
Showing
8 changed files
with
148 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ChatInput } from "./ChatInput"; | ||
import { Loader2Icon } from "lucide-react"; | ||
import { SwarmWithDataFragment, MessageRoleEnum } from "@/graphql/generated/graphql"; | ||
import { ChatMessages } from "./ChatMessages"; | ||
|
||
export function ChatContent({ swarm, isDialogMode }: { swarm: SwarmWithDataFragment | undefined, isDialogMode?: boolean }) { | ||
const messages = [ | ||
{ id: "1", content: "Hello, how are you?", role: MessageRoleEnum.User }, | ||
{ id: "2", content: "I'm fine, thank you!", role: MessageRoleEnum.Assistant }, | ||
{ id: "3", content: "What is your name?", role: MessageRoleEnum.User }, | ||
{ id: "4", content: "The question about context on my mind right now is more of a question of typing. There are two kinds of context: Operational and Node context. At the moment context is stored as a JSON column. The reason for this was because all the arguments being passed between actions became messy. But having unknown types is even worst. We could imagine for each ActionEnum defining a Pydantic type for it's node level context and it's spawn operation context. What about action and termination operations? In the first iteration we decoupled by every blocking operation, which wasn't strictly necessary. Now the only time we consider a node being \"blocked\" is when it needs to perform a search. And for a search node it's when it needs to ask the user questions. Those are two very specific points in the system and other than that I believe we can count on not having to think of blocking operations? Yet that is not true. We can easily imagine there being many more blocking operations and we need a standard way to handle them. So I think we might want to consider bringing back the Blocking Operation. In fact now we only have one Blocking Operation. Performing a search is a Spawn Operation.", role: MessageRoleEnum.Assistant }, | ||
{ id: "5", content: "The question about context on my mind right now is more of a question of typing. There are two kinds of context: Operational and Node context. At the moment context is stored as a JSON column. The reason for this was because all the arguments being passed between actions became messy. But having unknown types is even worst. We could imagine for each ActionEnum defining a Pydantic type for it's node level context and it's spawn operation context. What about action and termination operations? In the first iteration we decoupled by every blocking operation, which wasn't strictly necessary. Now the only time we consider a node being \"blocked\" is when it needs to perform a search. And for a search node it's when it needs to ask the user questions. Those are two very specific points in the system and other than that I believe we can count on not having to think of blocking operations? Yet that is not true. We can easily imagine there being many more blocking operations and we need a standard way to handle them. So I think we might want to consider bringing back the Blocking Operation. In fact now we only have one Blocking Operation. Performing a search is a Spawn Operation.", role: MessageRoleEnum.User }, | ||
]; | ||
|
||
return ( | ||
<div className="flex flex-col h-full"> | ||
{swarm === undefined ? ( | ||
<div className="flex-1 flex items-center justify-center"> | ||
<Loader2Icon className="animate-spin" size={32} /> | ||
</div> | ||
) : ( | ||
<div className="flex-1 overflow-y-auto"> | ||
<ChatMessages messages={messages} isDialogMode={isDialogMode} /> | ||
</div> | ||
)} | ||
<div className="w-full max-w-[800px] mx-auto px-4 pb-4"> | ||
<ChatInput /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useEffect, useRef } from "react"; | ||
import { MessageRoleEnum } from "@/graphql/generated/graphql"; | ||
|
||
interface Message { | ||
id: string; | ||
content: string; | ||
role: MessageRoleEnum; | ||
} | ||
|
||
interface UserMessageProps { | ||
content: string; | ||
} | ||
|
||
const UserMessage: React.FC<UserMessageProps> = ({ content }) => ( | ||
<div className="self-center w-[90%] max-w-[700px]"> | ||
<div className="flex justify-end"> | ||
<div className="inline-block bg-stone-700 rounded-3xl p-3 max-w-[77.78%] text-left"> | ||
{content} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
interface AiMessageProps { | ||
content: string; | ||
} | ||
|
||
const AiMessage: React.FC<AiMessageProps> = ({ content }) => ( | ||
<div className="self-center w-[90%] max-w-[700px]"> | ||
<div className="text-left rounded-3xl p-3"> | ||
{content} | ||
</div> | ||
</div> | ||
); | ||
|
||
interface ChatMessagesProps { | ||
messages: Message[]; | ||
isDialogMode?: boolean; | ||
} | ||
|
||
export function ChatMessages({ messages, isDialogMode }: ChatMessagesProps) { | ||
const messagesEndRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); | ||
}, [messages]); | ||
|
||
const heightClass = isDialogMode ? "h-[calc(100vh-163px)]" : "h-[calc(100vh-200px)]"; | ||
|
||
return ( | ||
<div className={`flex flex-col justify-start overflow-y-auto mt-10 gap-4 ${heightClass}`}> | ||
{messages.map((message) => ( | ||
message.role === MessageRoleEnum.User ? ( | ||
<UserMessage key={message.id} content={message.content} /> | ||
) : ( | ||
<AiMessage key={message.id} content={message.content} /> | ||
) | ||
))} | ||
<div ref={messagesEndRef} /> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters