forked from agentstack-ai/AgentStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagentstack_data.py
More file actions
124 lines (103 loc) · 3.36 KB
/
agentstack_data.py
File metadata and controls
124 lines (103 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import json
from datetime import datetime
from typing import Optional
from agentstack.utils import clean_input, get_version
from agentstack.logger import log
class ProjectMetadata:
def __init__(
self,
project_name: Optional[str] = None,
project_slug: Optional[str] = None,
description: str = "",
author_name: str = "",
version: str = "",
license: str = "",
year: int = datetime.now().year,
template: str = "none",
template_version: int = 0,
):
self.project_name = clean_input(project_name) if project_name else "myagent"
self.project_slug = clean_input(project_slug) if project_slug else self.project_name
self.description = description
self.author_name = author_name
self.version = version
self.license = license
self.year = year
self.agentstack_version = get_version()
self.template = template
self.template_version = template_version
log.debug(f"ProjectMetadata: {self.to_dict()}")
def to_dict(self):
return {
'project_name': self.project_name,
'project_slug': self.project_slug,
'description': self.description,
'author_name': self.author_name,
'version': self.version,
'license': self.license,
'year': self.year,
'agentstack_version': self.agentstack_version,
'template': self.template,
'template_version': self.template_version,
}
def to_json(self):
return json.dumps(self.to_dict(), default=str)
class ProjectStructure:
def __init__(
self,
method: str = "sequential",
manager_agent: Optional[str] = None,
):
self.agents = []
self.tasks = []
self.inputs = {}
self.method = method
self.manager_agent = manager_agent
def add_agent(self, agent):
self.agents.append(agent)
def add_task(self, task):
self.tasks.append(task)
def set_inputs(self, inputs):
self.inputs = inputs
def to_dict(self):
return {
'method': self.method,
'manager_agent': self.manager_agent,
'agents': self.agents,
'tasks': self.tasks,
'inputs': self.inputs,
}
def to_json(self):
return json.dumps(self.to_dict(), default=str)
class FrameworkData:
def __init__(
self,
# name: Optional[Literal["crewai"]] = None
name: Optional[str] = None, # TODO: better framework handling, Literal or Enum
):
self.name = name
def to_dict(self):
return {
'name': self.name,
}
def to_json(self):
return json.dumps(self.to_dict(), default=str)
class CookiecutterData:
def __init__(
self,
project_metadata: ProjectMetadata,
structure: ProjectStructure,
# framework: Literal["crewai"],
framework: str,
):
self.project_metadata = project_metadata
self.framework = framework
self.structure = structure
def to_dict(self):
return {
'project_metadata': self.project_metadata.to_dict(),
'framework': self.framework,
'structure': self.structure.to_dict(),
}
def to_json(self):
return json.dumps(self.to_dict(), default=str)