-
Notifications
You must be signed in to change notification settings - Fork 838
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
Showing
11 changed files
with
217 additions
and
107 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
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20230806211941_agent_description/migration.sql
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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Agent" ADD COLUMN "description" TEXT; |
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 |
---|---|---|
@@ -1,85 +1,151 @@ | ||
"use client"; | ||
import { useState } from "react"; | ||
import NextLink from "next/link"; | ||
import { | ||
Alert, | ||
Container, | ||
HStack, | ||
Button, | ||
Heading, | ||
Link, | ||
Icon, | ||
Stack, | ||
Tag, | ||
Text, | ||
useColorModeValue, | ||
HStack, | ||
SimpleGrid, | ||
Avatar, | ||
} from "@chakra-ui/react"; | ||
import dayjs from "dayjs"; | ||
import { TbPlayerPlay } from "react-icons/tb"; | ||
import relativeTime from "dayjs/plugin/relativeTime"; | ||
import SearchBar from "./_components/search-bar"; | ||
|
||
dayjs.extend(relativeTime); | ||
|
||
export default function HomeClientPage() { | ||
function LibraryCard({ id, name, description, createdAt, avatarUrl }) { | ||
return ( | ||
<Container maxWidth="3xl" minHeight="100vh"> | ||
<Stack | ||
paddingX={[4, 12]} | ||
paddingY={[6, 12]} | ||
spacing={12} | ||
flex={1} | ||
height="100vh" | ||
justifyContent={["flex-start", "center"]} | ||
> | ||
<Alert | ||
variant="outline" | ||
borderColor="orange.500" | ||
borderWidth="1px" | ||
borderRadius="md" | ||
> | ||
Superagent is in public beta, expect rapid updates. All feedback | ||
appreciated. | ||
</Alert> | ||
<Stack> | ||
<HStack> | ||
<Heading as="h1" fontSize="2xl"> | ||
Superagent | ||
</Heading> | ||
<Tag size="sm">Beta</Tag> | ||
<Stack borderWidth="1px" borderRadius="md" padding={4} spacing={4}> | ||
<Stack> | ||
<HStack justifyContent="space-between" flex={1}> | ||
<HStack spacing={4}> | ||
<Avatar size="sm" src={avatarUrl || "./logo.png"} /> | ||
<Text noOfLines={1} as="b" flex={1}> | ||
{name} | ||
</Text> | ||
</HStack> | ||
<Text> | ||
Superagent is a platform that enables you to create, manage and run | ||
AI Agents in seconds. We are currently in open beta so bare with us. | ||
Make sure the read the documentation on how to integrate Superagent | ||
with your app. | ||
<Text fontSize="sm" color="gray.500"> | ||
{dayjs(createdAt).fromNow()} | ||
</Text> | ||
</Stack> | ||
<NextLink passHref href="https://docs.superagent.sh"> | ||
<Stack | ||
minHeight="200px" | ||
bgGradient={useColorModeValue( | ||
"linear(to-l, gray.50, gray.200)", | ||
"linear(to-l, gray.600, gray.700)" | ||
)} | ||
justifyContent="flex-end" | ||
padding={8} | ||
borderRadius="lg" | ||
transition="0.2s all" | ||
_hover={{ transform: "scale(1.03)" }} | ||
> | ||
<Stack maxWidth={["full", "60%"]}> | ||
<Heading as="h1" fontSize="2xl"> | ||
Documentation | ||
</Heading> | ||
<Text> | ||
Read more on how to get started with integrating Superagent in | ||
your apps here. | ||
</Text> | ||
</Stack> | ||
</Stack> | ||
</NextLink> | ||
<Text> | ||
Contribute on{" "} | ||
<Link | ||
textDecoration="underline" | ||
href="https://github.com/homanp/superagent" | ||
> | ||
Github | ||
</Link> | ||
</HStack> | ||
<Text fontSize="sm" noOfLines={2} color="gray.500"> | ||
{description || "No description"} | ||
</Text> | ||
</Stack> | ||
</Container> | ||
<HStack justifyContent="space-between"> | ||
<NextLink passHref href={`/agents/${id}`}> | ||
<Button | ||
color="green.500" | ||
fontFamily="mono" | ||
size="sm" | ||
leftIcon={<Icon as={TbPlayerPlay} />} | ||
> | ||
RUN | ||
</Button> | ||
</NextLink> | ||
</HStack> | ||
</Stack> | ||
); | ||
} | ||
|
||
export default function HomeClientPage({ data }) { | ||
const [filteredData, setData] = useState(); | ||
|
||
const handleSearch = ({ searchTerm }) => { | ||
if (!searchTerm) { | ||
setData(data); | ||
} | ||
|
||
const keysToFilter = ["name"]; | ||
const filteredItems = data.filter((item) => | ||
keysToFilter.some((key) => | ||
item[key].toString().toLowerCase().includes(searchTerm.toLowerCase()) | ||
) | ||
); | ||
|
||
setData(filteredItems); | ||
}; | ||
|
||
return ( | ||
<Stack | ||
paddingX={[6, 12]} | ||
paddingY={12} | ||
spacing={6} | ||
flex={1} | ||
overflow="auto" | ||
> | ||
<HStack justifyContent="space-between"> | ||
<Stack> | ||
<Heading as="h1" fontSize="2xl"> | ||
Library | ||
</Heading> | ||
<Text color="gray.400" display={["none", "block"]}> | ||
Browse agents made by others | ||
</Text> | ||
</Stack> | ||
</HStack> | ||
<SearchBar | ||
onSearch={(values) => handleSearch(values)} | ||
onReset={() => setData(data)} | ||
/> | ||
<SimpleGrid columns={[1, 2, 2, 4]} gap={6}> | ||
{filteredData | ||
? filteredData?.map( | ||
({ | ||
id, | ||
avatarUrl, | ||
description, | ||
llm, | ||
createdAt, | ||
hasMemory, | ||
name, | ||
type, | ||
}) => ( | ||
<LibraryCard | ||
avatarUrl={avatarUrl} | ||
key={id} | ||
createdAt={createdAt} | ||
description={description} | ||
id={id} | ||
name={name} | ||
llm={llm} | ||
type={type} | ||
hasMemory={hasMemory} | ||
onDelete={(id) => handleDelete(id)} | ||
/> | ||
) | ||
) | ||
: data?.map( | ||
({ | ||
id, | ||
avatarUrl, | ||
description, | ||
llm, | ||
createdAt, | ||
hasMemory, | ||
name, | ||
type, | ||
}) => ( | ||
<LibraryCard | ||
avatarUrl={avatarUrl} | ||
key={id} | ||
createdAt={createdAt} | ||
description={description} | ||
id={id} | ||
name={name} | ||
llm={llm} | ||
type={type} | ||
hasMemory={hasMemory} | ||
onDelete={(id) => handleDelete(id)} | ||
/> | ||
) | ||
)} | ||
</SimpleGrid> | ||
</Stack> | ||
); | ||
} |
Oops, something went wrong.