Skip to content

Commit

Permalink
messing around with eliza
Browse files Browse the repository at this point in the history
  • Loading branch information
OleanjiKingCode committed Jan 21, 2025
1 parent e154215 commit 84f16b9
Show file tree
Hide file tree
Showing 48 changed files with 5,504 additions and 830 deletions.
2 changes: 2 additions & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-pear": "workspace:*",
"@elizaos/plugin-news": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
Expand Down
3 changes: 3 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
import { RedisClient } from "@elizaos/adapter-redis";
import { zgPlugin } from "@elizaos/plugin-0g";
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
import { pearPlugin } from "@elizaos/plugin-pear";
import { NewsPlugin } from "@elizaos/plugin-news";
import createGoatPlugin from "@elizaos/plugin-goat";
// import { intifacePlugin } from "@elizaos/plugin-intiface";
import { DirectClient } from "@elizaos/client-direct";
Expand Down Expand Up @@ -525,6 +527,7 @@ export async function createAgent(
// character.plugins are handled when clients are added
plugins: [
bootstrapPlugin,
NewsPlugin,
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
? confluxPlugin
: null,
Expand Down
4 changes: 2 additions & 2 deletions characters/tate.character.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tate",
"clients": [],
"modelProvider": "anthropic",
"clients": ["telegram"],
"modelProvider": "openai",
"settings": {
"secrets": {},
"voice": {
Expand Down
23 changes: 14 additions & 9 deletions client/src/Agents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ import { Button } from "@/components/ui/button";
import { useNavigate } from "react-router-dom";
import { useGetAgentsQuery } from "@/api";
import "./App.css";
import { Loader2Icon } from "lucide-react";

function Agents() {
const navigate = useNavigate();
const { data: agents, isLoading } = useGetAgentsQuery()

return (
<div className="min-h-screen flex flex-col items-center justify-center p-4">
<h1 className="text-2xl font-bold mb-8">Select your agent:</h1>
<div className="min-h-screen flex flex-col items-center p-4 w-full ">
<h1 className="text-2xl font-bold mb-8">Your AI agents</h1>

{isLoading ? (
<div>Loading agents...</div>
<div className="flex items-center gap-4">
<span>Fetching your agents...</span>
<Loader2Icon className="animate-spin h-5 w-5"/>
</div>
) : (
<div className="grid gap-4 w-full max-w-md">
<div className="grid gap-4 grid-cols-4 w-full">
{agents?.map((agent) => (
<div key={agent.id} className="h-52 rounded-md flex flex-col justify-end bg-neutral-300" onClick={() => {
navigate(`/${agent.id}`);
}}>

<Button
key={agent.id}
className="w-full text-lg py-6"
onClick={() => {
navigate(`/${agent.id}`);
}}
className="w-full text-lg py-6 rounded-b-lg rounded-t-none"
>
{agent.name}
</Button>
</div>
))}
</div>
)}
Expand Down
1 change: 0 additions & 1 deletion client/src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#root {
max-width: 1280px;
margin: 0 auto;
text-align: center;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Agents from "./Agents";

function App() {
return (
<div className="min-h-screen flex flex-col items-center justify-center p-4">
<div className="min-h-screen flex flex-col items-center justify-center p-4 bg-[#121212]">
<Agents />
</div>
);
Expand Down
58 changes: 39 additions & 19 deletions client/src/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export default function Chat() {
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const messagesEndRef = useRef<HTMLDivElement>(null);
const { mutate: sendMessage, isPending } = useSendMessageMutation({ setMessages, setSelectedFile });
const { mutate: sendMessage, isPending } = useSendMessageMutation({
setMessages,
setSelectedFile,
});

const scrollToBottom = () => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
Expand All @@ -32,7 +35,15 @@ export default function Chat() {
const userMessage: TextResponse = {
text: input,
user: "user",
attachments: selectedFile ? [{ url: URL.createObjectURL(selectedFile), contentType: selectedFile.type, title: selectedFile.name }] : undefined,
attachments: selectedFile
? [
{
url: URL.createObjectURL(selectedFile),
contentType: selectedFile.type,
title: selectedFile.name,
},
]
: undefined,
};
setMessages((prev) => [...prev, userMessage]);

Expand All @@ -46,7 +57,7 @@ export default function Chat() {

const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file && file.type.startsWith('image/')) {
if (file && file.type.startsWith("image/")) {
setSelectedFile(file);
}
};
Expand All @@ -73,22 +84,31 @@ export default function Chat() {
}`}
>
{message.text}
{message.attachments?.map((attachment, i) => (
attachment.contentType.startsWith('image/') && (
<img
key={i}
src={message.user === "user"
? attachment.url
: attachment.url.startsWith('http')
? attachment.url
: `http://localhost:3000/media/generated/${attachment.url.split('/').pop()}`
}
alt={attachment.title || "Attached image"}
className="mt-2 max-w-full rounded-lg"
/>
)
))}
</pre>
{message.attachments?.map(
(attachment, i) =>
attachment.contentType.startsWith(
"image/"
) && (
<img
key={i}
src={
message.user === "user"
? attachment.url
: attachment.url.startsWith(
"http"
)
? attachment.url
: `http://localhost:3000/media/generated/${attachment.url.split("/").pop()}`
}
alt={
attachment.title ||
"Attached image"
}
className="mt-2 max-w-full rounded-lg"
/>
)
)}
</pre>
</div>
))
) : (
Expand Down
2 changes: 1 addition & 1 deletion client/src/api/queries/useGetAgentsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useGetAgentsQuery = (): CustomQueryResult<Agent[] | undefined> => {
return data.agents as Agent[];
},
retry: (failureCount) => failureCount < 3,
staleTime: 5 * 60 * 1000, // 5 minutes
staleTime: 5 * 60 * 1000,
refetchOnWindowFocus: false,
});
};
Loading

0 comments on commit 84f16b9

Please sign in to comment.