-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Agent creation frontend (#1836)
Issue: #1832 Demo: https://github.com/StanGirard/quivr/assets/63923024/e9c0e9b8-04b1-4f12-a8ef-b27f0f489e48 <img width="1503" alt="Screenshot 2023-12-06 at 15 23 12" src="https://github.com/StanGirard/quivr/assets/63923024/11e6960b-c1c3-4abf-aeed-c226f034246f"> <img width="1503" alt="Screenshot 2023-12-06 at 15 23 23" src="https://github.com/StanGirard/quivr/assets/63923024/09681a9d-ce2e-42bb-8151-1986e27f7312">
- Loading branch information
1 parent
90c4a44
commit d9f6ce4
Showing
19 changed files
with
175 additions
and
14 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
35 changes: 35 additions & 0 deletions
35
...tep/components/CompositeBrainConnections/Components/ConnectableBrain/ConnectableBrain.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,35 @@ | ||
import { Checkbox } from "@/lib/components/ui/Checkbox"; | ||
import { MinimalBrainForUser } from "@/lib/context/BrainProvider/types"; | ||
|
||
import { useConnectableBrain } from "./hooks/useConnectableBrain"; | ||
|
||
type ConnectableBrainProps = { | ||
brain: MinimalBrainForUser; | ||
}; | ||
|
||
export const ConnectableBrain = ({ | ||
brain, | ||
}: ConnectableBrainProps): JSX.Element => { | ||
const { onCheckedChange } = useConnectableBrain(); | ||
|
||
return ( | ||
<div className="flex flex-row items-center gap-2"> | ||
<Checkbox | ||
className="text-white" | ||
onCheckedChange={(checked) => | ||
onCheckedChange({ | ||
brainId: brain.id, | ||
checked, | ||
}) | ||
} | ||
id={`connected_brains_ids-${brain.id}`} | ||
/> | ||
<label | ||
htmlFor={`connected_brains_ids-${brain.id}`} | ||
className="text-md font-medium leading-none cursor-pointer" | ||
> | ||
{brain.name} | ||
</label> | ||
</div> | ||
); | ||
}; |
35 changes: 35 additions & 0 deletions
35
...onents/CompositeBrainConnections/Components/ConnectableBrain/hooks/useConnectableBrain.ts
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,35 @@ | ||
import { CheckedState } from "@radix-ui/react-checkbox"; | ||
import { UUID } from "crypto"; | ||
import { useFormContext } from "react-hook-form"; | ||
|
||
import { CreateBrainProps } from "@/lib/components/AddBrainModal/types"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export const useConnectableBrain = () => { | ||
const { setValue, getValues } = useFormContext<CreateBrainProps>(); | ||
|
||
const onCheckedChange = ({ | ||
checked, | ||
brainId, | ||
}: { | ||
checked: CheckedState; | ||
brainId: UUID; | ||
}) => { | ||
if (checked === "indeterminate") { | ||
return; | ||
} | ||
const connected_brains_ids = getValues("connected_brains_ids") ?? []; | ||
if (checked) { | ||
setValue("connected_brains_ids", [...connected_brains_ids, brainId]); | ||
} else { | ||
setValue( | ||
"connected_brains_ids", | ||
connected_brains_ids.filter((id) => id !== brainId) | ||
); | ||
} | ||
}; | ||
|
||
return { | ||
onCheckedChange, | ||
}; | ||
}; |
24 changes: 24 additions & 0 deletions
24
...nts/BrainKnowledgeStep/components/CompositeBrainConnections/CompositeBrainConnections.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,24 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; | ||
|
||
import { ConnectableBrain } from "./Components/ConnectableBrain/ConnectableBrain"; | ||
|
||
export const CompositeBrainConnections = (): JSX.Element => { | ||
const { allBrains } = useBrainContext(); | ||
const sortedBrains = allBrains.sort((a, b) => a.name.localeCompare(b.name)); | ||
const { t } = useTranslation("brain"); | ||
|
||
return ( | ||
<div className="px-10"> | ||
<p className="text-center mb-8 italic text-sm w-full"> | ||
{t("composite_brain_composition_invitation")} | ||
</p> | ||
<div className="w-full flex flex-col gap-2"> | ||
{sortedBrains.map((brain) => ( | ||
<ConnectableBrain key={brain.id} brain={brain} /> | ||
))} | ||
</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
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,26 @@ | ||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; | ||
import * as React from "react"; | ||
import { LuCheck } from "react-icons/lu"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
export const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn("flex items-center justify-center text-current")} | ||
> | ||
<LuCheck className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)); | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName; |
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
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