forked from cohere-ai/cohere-toolkit
-
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.
Merge branch 'cohere-ai:main' into main
- Loading branch information
Showing
19 changed files
with
375 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
40 changes: 40 additions & 0 deletions
40
src/interfaces/coral_web/src/components/Agents/AddAgentButton.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react'; | ||
import Link from 'next/link'; | ||
|
||
import { Icon, Text } from '@/components/Shared'; | ||
|
||
/** | ||
* @description renders a button to add a new agent. | ||
*/ | ||
export const AddAgentButton: React.FC = () => { | ||
return ( | ||
<Menu> | ||
<MenuButton className="group h-8 w-8 rounded border border-marble-500 p-px"> | ||
<div className="flex h-full w-full items-center justify-center rounded bg-green-50 transition-colors duration-300 group-hover:bg-green-100/80"> | ||
<Icon name="add" className="text-volcanic-800" /> | ||
</div> | ||
</MenuButton> | ||
<MenuItems | ||
anchor="right start" | ||
className="z-menu ml-3 rounded bg-white px-2 py-1 shadow-menu" | ||
> | ||
<MenuItem | ||
as={Link} | ||
href="/agents/new" | ||
className="flex w-full items-center gap-x-2 rounded bg-white p-2 hover:bg-secondary-50" | ||
> | ||
<Icon name="add" className="text-secondary-700" /> | ||
<Text>Create new agent</Text> | ||
</MenuItem> | ||
<div className="my-1 h-px w-full border-t border-marble-400" /> | ||
<MenuItem | ||
as="button" | ||
className="flex w-full items-center gap-x-2 rounded bg-white p-2 hover:bg-secondary-50" | ||
> | ||
<Icon name="circles-four" className="text-secondary-700" /> | ||
<Text>Add an existing agent</Text> | ||
</MenuItem> | ||
</MenuItems> | ||
</Menu> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/interfaces/coral_web/src/components/Agents/BaseAgentButton.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Link from 'next/link'; | ||
|
||
import { CoralLogo } from '@/components/Shared'; | ||
|
||
/** | ||
* @description renders a button to navigate to the default knowledge agent page. | ||
*/ | ||
export const BaseAgentButton: React.FC = () => { | ||
return ( | ||
<Link className="group h-8 w-8 rounded border border-marble-500 p-[1px]" href="/agents"> | ||
<div className="flex h-full w-full items-center justify-center rounded bg-secondary-400 transition-colors duration-300 group-hover:bg-secondary-500"> | ||
<CoralLogo style="secondary" /> | ||
</div> | ||
</Link> | ||
); | ||
}; |
102 changes: 102 additions & 0 deletions
102
src/interfaces/coral_web/src/components/Agents/Layout.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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { Transition } from '@headlessui/react'; | ||
import { capitalize } from 'lodash'; | ||
import React, { Children, PropsWithChildren, useContext } from 'react'; | ||
|
||
import { ConfigurationDrawer } from '@/components/Conversation/ConfigurationDrawer'; | ||
import { DeploymentsDropdown } from '@/components/DeploymentsDropdown'; | ||
import { EditEnvVariablesButton } from '@/components/EditEnvVariablesButton'; | ||
import { Banner } from '@/components/Shared'; | ||
import { NavigationBar } from '@/components/Shared/NavigationBar/NavigationBar'; | ||
import { PageHead } from '@/components/Shared/PageHead'; | ||
import { BannerContext } from '@/context/BannerContext'; | ||
import { useIsDesktop } from '@/hooks/breakpoint'; | ||
import { useSettingsStore } from '@/stores'; | ||
import { cn } from '@/utils/cn'; | ||
|
||
export const LeftSection: React.FC<React.PropsWithChildren> = ({ children }) => <>{children}</>; | ||
export const MainSection: React.FC<React.PropsWithChildren> = ({ children }) => <>{children}</>; | ||
|
||
type Props = { | ||
title?: string; | ||
} & PropsWithChildren; | ||
|
||
/** | ||
* This component is in charge of layout out the entire page. | ||
* It shows the navigation bar, the left drawer and main content. | ||
* On small devices (e.g. mobile), the left drawer and main section are stacked vertically. | ||
*/ | ||
export const Layout: React.FC<Props> = ({ title = 'Chat', children }) => { | ||
const { message: bannerMessage } = useContext(BannerContext); | ||
const { | ||
settings: { isConvListPanelOpen, isMobileConvListPanelOpen }, | ||
} = useSettingsStore(); | ||
const isDesktop = useIsDesktop(); | ||
|
||
let leftElement: React.ReactNode = null; | ||
let mainElement: React.ReactNode = null; | ||
|
||
Children.toArray(children).forEach((child: React.ReactNode) => { | ||
const element = child as React.ReactElement; | ||
|
||
if (element.type === LeftSection) { | ||
leftElement = child; | ||
return; | ||
} | ||
if (element.type === MainSection) { | ||
mainElement = child; | ||
return; | ||
} | ||
}); | ||
|
||
return ( | ||
<> | ||
<PageHead title={capitalize(title)} /> | ||
<div className="flex h-screen w-full flex-1 flex-col gap-3 bg-secondary-100 p-3"> | ||
<NavigationBar> | ||
<span className="flex items-center gap-x-2"> | ||
<DeploymentsDropdown /> | ||
<EditEnvVariablesButton className="py-0" /> | ||
</span> | ||
</NavigationBar> | ||
{bannerMessage && <Banner size="sm">{bannerMessage}</Banner>} | ||
|
||
<div className={cn('relative flex h-full flex-grow flex-nowrap gap-3 overflow-hidden')}> | ||
<div | ||
className={cn( | ||
'w-16 px-4 py-6 lg:flex-grow-0', | ||
'flex flex-grow flex-col rounded-lg border', | ||
'border-marble-400 bg-marble-100' | ||
)} | ||
> | ||
{leftElement} | ||
</div> | ||
<Transition | ||
as="main" | ||
show={!isMobileConvListPanelOpen || isDesktop} | ||
enterFrom="translate-x-full lg:translate-x-0" | ||
enterTo="translate-x-0" | ||
leaveFrom="translate-x-0" | ||
leaveTo="translate-x-full lg:translate-x-0" | ||
className={cn( | ||
'z-main-section flex flex-grow lg:min-w-0', | ||
'absolute h-full w-full lg:static lg:h-auto', | ||
'transition-transform duration-500 ease-in-out lg:transition-none' | ||
)} | ||
> | ||
<section | ||
className={cn( | ||
'relative flex h-full min-w-0 flex-grow flex-col', | ||
'rounded-lg border', | ||
'border-marble-400 bg-marble-100', | ||
'overflow-hidden' | ||
)} | ||
> | ||
{mainElement} | ||
</section> | ||
</Transition> | ||
<ConfigurationDrawer /> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
14 changes: 14 additions & 0 deletions
14
src/interfaces/coral_web/src/components/Agents/LeftPanel.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AddAgentButton } from '@/components/Agents/AddAgentButton'; | ||
import { BaseAgentButton } from '@/components/Agents/BaseAgentButton'; | ||
|
||
/** | ||
* @description renders the left panel containing the base agent, a list of agents, and an add agent button. | ||
*/ | ||
export const LeftPanel: React.FC = () => { | ||
return ( | ||
<div className="flex flex-col gap-3"> | ||
<BaseAgentButton /> | ||
<AddAgentButton /> | ||
</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
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
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
Oops, something went wrong.