-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
building out conversations / multiple chats
- Loading branch information
Showing
5 changed files
with
174 additions
and
67 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
108 changes: 70 additions & 38 deletions
108
submodules/moragents_dockers/agents/src/stores/chat_manager.py
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
82 changes: 63 additions & 19 deletions
82
submodules/moragents_dockers/frontend/components/LeftSidebar/index.tsx
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 |
---|---|---|
@@ -1,24 +1,68 @@ | ||
import React, { FC } from 'react'; | ||
import { | ||
Box, | ||
VStack, | ||
Text, | ||
Link | ||
} from "@chakra-ui/react"; | ||
import { ConnectButton } from '@rainbow-me/rainbowkit'; | ||
import React, { FC, useEffect, useState } from "react"; | ||
import { Box, VStack, Text, Button } from "@chakra-ui/react"; | ||
import { getHttpClient } from "@/services/constants"; | ||
|
||
export type LeftSidebarProps = {}; | ||
|
||
export type LeftSidebarProps = { | ||
export const LeftSidebar: FC<LeftSidebarProps> = () => { | ||
const [conversations, setConversations] = useState<string[]>([]); | ||
|
||
}; | ||
const fetchConversations = async () => { | ||
try { | ||
const response = await getHttpClient().get("/chat/conversations"); | ||
setConversations(response.data.conversation_ids); | ||
} catch (error) { | ||
console.error("Failed to fetch conversations:", error); | ||
} | ||
}; | ||
|
||
export const LeftSidebar: FC<LeftSidebarProps> = () => { | ||
return ( | ||
<Box bg="#020804" p={4}> | ||
<VStack align="stretch" height="85%"> | ||
const createNewConversation = async () => { | ||
try { | ||
await getHttpClient().post("/chat/conversations"); | ||
fetchConversations(); | ||
} catch (error) { | ||
console.error("Failed to create new conversation:", error); | ||
} | ||
}; | ||
|
||
{/* Dynamic chat list can be added here */} | ||
</VStack> | ||
</Box> | ||
); | ||
} | ||
const deleteConversation = async (conversationId: string) => { | ||
try { | ||
await getHttpClient().delete(`/chat/conversations/${conversationId}`); | ||
fetchConversations(); | ||
} catch (error) { | ||
console.error("Failed to delete conversation:", error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchConversations(); | ||
}, []); | ||
|
||
return ( | ||
<Box bg="#020804" p={4}> | ||
<VStack align="stretch" height="85%" spacing={4}> | ||
<Button onClick={createNewConversation}>New Chat</Button> | ||
{conversations.map((conversationId) => ( | ||
<Box | ||
key={conversationId} | ||
p={3} | ||
bg="#1A1A1A" | ||
borderRadius="md" | ||
display="flex" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Text color="white">{conversationId}</Text> | ||
<Button | ||
size="sm" | ||
colorScheme="red" | ||
onClick={() => deleteConversation(conversationId)} | ||
> | ||
Delete | ||
</Button> | ||
</Box> | ||
))} | ||
</VStack> | ||
</Box> | ||
); | ||
}; |
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