Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V.20 #338

Merged
merged 7 commits into from
Nov 21, 2024
Merged

V.20 #338

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions agenthub/app/cerebrum/tools/download/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { NextResponse } from 'next/server';
import prisma from '../../../../lib/prisma'

export async function GET(request: Request): Promise<NextResponse> {
const { searchParams } = new URL(request.url);
const name = searchParams.get('name');
const version = searchParams.get('version');
const author = searchParams.get('author');

if (name && version && author) {
const result = await prisma.cerebrumTool.findFirst({
where: {
name,
version,
author
},
include: {
files: true
}
});

if (result != null) {
return NextResponse.json({ ...result });
}
} else if (name && author) {
const result = await prisma.cerebrumTool.findFirst({
where: {
name,
author
},
orderBy: {
version: 'desc'
},
include: {
files: true
}
});

if (result != null) {
return NextResponse.json({ ...result });
}

}

return NextResponse.json({ status: 'fail' });
}
10 changes: 10 additions & 0 deletions agenthub/app/cerebrum/tools/list/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const dynamic = 'force-dynamic'

import { NextResponse } from 'next/server';
import prisma from '../../../../lib/prisma'

export async function GET(request: Request): Promise<NextResponse> {
const result = await prisma.cerebrumTool.findMany();

return NextResponse.json({...result});
}
41 changes: 41 additions & 0 deletions agenthub/app/cerebrum/tools/upload/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { NextResponse } from 'next/server';
import prisma from '../../../../lib/prisma'

export async function POST(request: Request): Promise<NextResponse> {
if (request.body) {
const body = await request.json();

// Destructure the body to separate agent data from files
const { author, name, version, license, files, ...otherData } = body;
console.log(body)

try {
const result = await prisma.cerebrumTool.create({
data: {
author,
name,
version,
license,
...otherData,
files: {
//@ts-ignore
create: files.map((file: any) => ({
path: file.path,
content: file.content
}))
}
},
include: {
files: true
}
});

return NextResponse.json(result);
} catch (error) {
console.error('Error creating agent:', error);
return NextResponse.json({ status: 'error', message: 'Failed to create tool' }, { status: 500 });
}
} else {
return NextResponse.json({ status: 'fail', message: 'No body provided' }, { status: 400 });
}
}
71 changes: 39 additions & 32 deletions agenthub/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions agenthub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@mantine/spotlight": "^7.13.2",
"@mantine/tiptap": "^7.13.2",
"@nextui-org/react": "^2.4.8",
"@prisma/client": "^5.19.1",
"@prisma/client": "^5.22.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-popover": "^1.1.1",
Expand Down Expand Up @@ -52,7 +52,6 @@
"lucide-react": "^0.441.0",
"next": "^14.2.12",
"npm": "^10.8.3",
"prisma": "^5.19.1",
"quill": "^2.0.2",
"quill-mention": "^6.0.1",
"react": "^18",
Expand Down Expand Up @@ -80,6 +79,7 @@
"postcss": "^8.4.47",
"postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1",
"prisma": "^5.22.0",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
Expand Down
27 changes: 27 additions & 0 deletions agenthub/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,31 @@ model CerebrumAgentFile {
agent CerebrumAgent @relation(fields: [agentId], references: [id])

@@unique([agentId, path])
}

model CerebrumTool {
id String @id @default(cuid())
author String
name String
version String
license String
entry String
module String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
description String @default("No Description Provided")

files CerebrumToolFile[]

@@unique([author, name, version])
}

model CerebrumToolFile {
id String @id @default(cuid())
toolId String
path String
content String @db.Text // Changed from Bytes to String
tool CerebrumTool @relation(fields: [toolId], references: [id])

@@unique([toolId, path])
}
78 changes: 78 additions & 0 deletions aios/core/syscall/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

from threading import Event, Thread

from cerebrum.llm.communication import Request


class Syscall(Thread):
def __init__(self, agent_name, query: Request):
super().__init__()
self.agent_name = agent_name
self.query = query
self.event = Event()
self.pid: int = None
self.status = None
self.response = None
self.time_limit = None
self.created_time = None
self.start_time = None
self.end_time = None

def set_created_time(self, time):
self.created_time = time

def get_created_time(self):
return self.created_time

def set_start_time(self, time):
self.start_time = time

def get_start_time(self):
return self.start_time

def set_end_time(self, time):
self.end_time = time

def get_end_time(self):
return self.end_time

def set_priority(self, priority):
self.priority = priority

def get_priority(self):
return self.priority

def set_status(self, status):
self.status = status

def get_status(self):
return self.status

def set_aid(self, aid):
self.aid = aid

def get_aid(self):
return self.pid

def set_pid(self, pid):
self.pid = pid

def get_pid(self):
return self.pid

def get_response(self):
return self.response

def set_response(self, response):
self.response = response

def get_time_limit(self):
return self.time_limit

def set_time_limit(self, time_limit):
self.time_limit = time_limit

def run(self):
self.set_pid(self.native_id)
self.event.wait()

4 changes: 4 additions & 0 deletions aios/core/syscall/llm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from aios.core.syscall import Syscall

class LLMSyscall(Syscall):
pass
5 changes: 5 additions & 0 deletions aios/core/syscall/memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from aios.core.syscall import Syscall


class MemorySyscall(Syscall):
pass
4 changes: 4 additions & 0 deletions aios/core/syscall/storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from aios.core.syscall import Syscall

class StorageSyscall(Syscall):
pass
6 changes: 6 additions & 0 deletions aios/core/syscall/tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from aios.core.syscall import Syscall

class ToolSyscall(Syscall):
def __init__(self, agent_name, request):
super().__init__(agent_name, request)
self.tool_calls = request
File renamed without changes.
Loading