-
Notifications
You must be signed in to change notification settings - Fork 1
/
staff_ai.gleam
163 lines (155 loc) · 5.84 KB
/
staff_ai.gleam
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/// Staff-AI is the easiest and most scalable way to build and deploy AI agents for accomplishing tasks for you.
/// Define your employees, their tasks, and the environment they work in, and let Staff-AI handle the rest.
///
/// Staff-AI is built on top of the Gleam programming language, and is designed to be easy to use, easy to understand,
/// and easy to extend. With Staff-AI, you can build AI agents that can do anything from simple data entry to complex
/// research and development tasks.
///
/// Why not Python? Python is a great language, but it's not designed for building scalable, concurrent, and distributed
/// systems. Gleam is built on top of the Erlang VM, which is designed for building scalable, concurrent, and distributed
/// systems. This makes it the perfect language for building AI agents that can work together to accomplish tasks.
///
/// We don't want you to run maximum 3 agents at a time, we want you to run as many agents as you need to accomplish
/// your tasks as quickly as possible. Imagine being the CEO of a company with 1000 AI agents working for you, all
/// accomplishing tasks for you on a low-cost cloud infrastructure. That's the power of Staff-AI.
///
/// Copyright (c) 2024 Staff-AI - All rights reserved
///
import birl
import gleam/option.{type Option, None}
import ids/uuid
/// Represents a unique identifier, which is a string in the UUID format.
///
pub type UUID =
String
/// The status of the task
///
pub type TaskStatus {
/// The task is ready to be performed
Ready
/// The task is currently being performed
InProgress
/// The task has been completed
Completed
/// The task has been cancelled
Cancelled
/// The task has failed
Failed
}
/// A task that can be performed by an agent
///
/// It represents the most simple unit of work that an Agent can perform.
/// The task can involve any input and output, but it is expected to be
/// a small unit of work that can be performed in a short amount of time.
///
pub type Task {
Task(
/// The unique identifier of the task
id: UUID,
/// A meaningful title of the task
title: String,
/// A description of the task, must be detailed enough to be performed
description: String,
/// The status of the task
status: TaskStatus,
/// The unique identifier of the agent that has been assigned to perform the task
assigned_agent: Option(UUID),
/// The time when the task was created
created_at: birl.Time,
/// The time when the task was last updated
updated_at: birl.Time,
/// The time when the task was completed
completed_at: Option(birl.Time),
/// The time when the task was cancelled
cancelled_at: Option(birl.Time),
/// The time when the task has failed
failed_at: Option(birl.Time),
)
}
/// Create a new task
///
pub fn create_task(
title: String,
description: String,
assigned_agent: Option(UUID),
) -> Task {
let assert Ok(id) = uuid.generate_v4()
let created_at = birl.now()
Task(
id: id,
title: title,
description: description,
status: Ready,
assigned_agent: assigned_agent,
created_at: created_at,
updated_at: created_at,
completed_at: None,
cancelled_at: None,
failed_at: None,
)
}
/// Represents an AI worker in a staff system
///
/// It represents the most simple unit of you staff who can be assigned to a task.
/// Agent has a name, a list of skills and a list of tasks, which he is currently working on.
///
pub type Agent {
Agent(
/// Unique identifier of the agent
id: UUID,
/// Name of the agent, which is used to identify him in your system.
/// It can be a real name or a nickname, e.g. "Jane Doe" or "jane_doe"
name: String,
/// Role of the agent, which is used to identify his skills and responsibilities in your system.
/// It can be a real role or a nickname, e.g. "Software Developer" or "dev"
role: String,
/// Adding a context to an agent is optional, but it can be useful to store additional information about the agent.
/// It can be used to store additional information about the agent as it will influence the way it reacts to tasks.
/// E.g. "Jane Doe is a technical lead of the project X. She is responsible for the architecture and ..."
context: Option(String),
)
}
/// Creates a new agent with the given parameters.
///
pub fn create_agent(
name: String,
role: String,
context: Option(String),
) -> Agent {
let assert Ok(id) = uuid.generate_v4()
Agent(id: id, name: name, role: role, context: context)
}
/// Squad is a group of agents that can are working together on a specific Objective.
///
/// It represents isolated groups of agents with diverse skills and responsibilities.
/// The squad has a name, an objective and a list of agents, which are part of the squad.
///
pub type Squad {
Squad(
/// Unique identifier of the squad
id: UUID,
/// Name of the squad, which is used to identify it in your system.
/// It can be a real name or a nickname, e.g. "Software Development Team" or "dev_team"
name: String,
/// Objective of the squad, which is used to identify the goal of the squad in your system.
/// It can be a real objective or a nickname, e.g. "Develop the new feature X" or "feature_x"
/// The objective should be as clear as possible to be sub-divided into granular tasks.
objective: String,
/// The list of agents that are part of the squad, this list can evolve over time.
agents: List(Agent),
/// The list of tasks that are part of the squad, this list will evolve over time
/// as tasks are created and completed.
tasks: List(Task),
)
}
/// Creates a new squad with the given parameters.
///
pub fn create_squad(
name: String,
objective: String,
agents: List(Agent),
tasks: List(Task),
) -> Squad {
let assert Ok(id) = uuid.generate_v4()
Squad(id: id, name: name, objective: objective, agents: agents, tasks: tasks)
}