Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c2261d4
LangGraph stubs
tcdent Jan 7, 2025
8e6ef7b
Merge branch 'main' into langgraph
tcdent Jan 10, 2025
c3c8d40
LangGraph support.
tcdent Jan 14, 2025
03f8283
Add `graph` data structure to project templates and implement in Lang…
tcdent Jan 14, 2025
698b960
Merge branch 'main' into langgraph
tcdent Jan 15, 2025
fb6146b
Implement adding and removing tools from LangGraph projects. Move Lan…
tcdent Jan 15, 2025
d87c8b3
Get all tests passing.
tcdent Jan 15, 2025
f03add4
Can't use variable as Literal.
tcdent Jan 15, 2025
5f24c49
Code coverage for langgraph framework implementation.
tcdent Jan 15, 2025
3eb6346
Merge branch 'main' into langgraph
tcdent Jan 16, 2025
a235a4a
Add get_tool_callables to langgraph framework.
tcdent Jan 16, 2025
dfc887e
LangGraph tool callables bugfix.
tcdent Jan 16, 2025
743297d
ToolConfig should raise exceptions instead of exit.
tcdent Jan 16, 2025
0641b1b
Partial tests for frameworks.get_tool_callables
tcdent Jan 16, 2025
0f0de88
Remove empty file
tcdent Jan 16, 2025
e945223
Exclude abstract Protocol from test coverage.
tcdent Jan 16, 2025
a41b6d2
Fix imports for AgentConfig / frameworks.
tcdent Jan 16, 2025
3b249f3
Allow manipulating the graph inside of a LangGraph project.
tcdent Jan 16, 2025
eb5dd66
Use tasks.yaml and agents.yaml for lookup of agents and tasks when ex…
tcdent Jan 17, 2025
510d998
Support adding graph nodes where there are no existing nodes
tcdent Jan 17, 2025
f531884
Allow specifying position to insert new agents into the graph.
tcdent Jan 17, 2025
e693c8c
Supoort adding node edges where no start/end node exists yet.
tcdent Jan 17, 2025
6d5f81e
Remove unused methods.
tcdent Jan 17, 2025
cddafe4
Install dependencies and add import statements for third party LangCh…
tcdent Jan 17, 2025
2fbdd8e
Fix type checking.
tcdent Jan 17, 2025
2d66797
Bugfixes, tests for imports.
tcdent Jan 17, 2025
25fbfbb
Update coverage exclusions
tcdent Jan 17, 2025
a40b0e7
Cleanup coverage exclusion comments
tcdent Jan 17, 2025
fd0898d
Configurable positions for inserting tasks.
tcdent Jan 17, 2025
1bf5b5a
Cleanup print statements in CLI init commands.
tcdent Jan 17, 2025
acd1d38
Refactor CLI `init` to dynamically insert agents, tasks & tools after…
tcdent Jan 18, 2025
e7d8c60
Add langchain as a dependency, remove langgraph
tcdent Jan 20, 2025
a2f3ee8
Merge branch 'main' into langgraph
tcdent Jan 20, 2025
8b61ffb
template readme
bboynton97 Jan 21, 2025
e1e9756
readme and template changes
bboynton97 Jan 22, 2025
2b87a69
Merge branch 'main' into langgraph
bboynton97 Jan 23, 2025
7facf9b
manually capture langgraph tool use
bboynton97 Jan 23, 2025
2ac1e34
Fix LangGraph tool use.
tcdent Jan 23, 2025
60ad579
allow delegation warning fix
bboynton97 Jan 23, 2025
4a4e64c
better printing
bboynton97 Jan 23, 2025
305c944
Add `agent.bind_tools` when first tool is added. #231
tcdent Jan 24, 2025
3d79347
version bump
bboynton97 Jan 24, 2025
8676d68
Fix wizard!
tcdent Jan 24, 2025
0467a79
Migrate project metadata to standard format (not poetry).
tcdent Jan 24, 2025
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
35 changes: 30 additions & 5 deletions agentstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,42 @@
from pathlib import Path
from agentstack import conf
from agentstack.utils import get_framework
from agentstack.agents import get_agent
from agentstack.tasks import get_task
from agentstack.inputs import get_inputs
from agentstack import frameworks

___all___ = [
"conf",
"tools",
"get_tags",
"get_framework",
"get_inputs",
"conf",
"agent",
"task",
"tools",
"get_tags",
"get_framework",
"get_agent",
"get_task",
"get_inputs",
]

def agent(func):
"""
The `agent` decorator is used to mark a method that implements an Agent.
"""
def wrap(*args, **kwargs):

Check warning on line 33 in agentstack/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/__init__.py#L33

Added line #L33 was not covered by tests
"""Does not alter the function's behavior; this is just a marker."""
return func(*args, **kwargs)
return wrap

Check warning on line 36 in agentstack/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/__init__.py#L35-L36

Added lines #L35 - L36 were not covered by tests


def task(func):
"""
The `task` decorator is used to mark a method that implements a Task.
"""
def wrap(*args, **kwargs):

Check warning on line 43 in agentstack/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/__init__.py#L43

Added line #L43 was not covered by tests
"""Does not alter the function's behavior; this is just a marker."""
return func(*args, **kwargs)
return wrap

Check warning on line 46 in agentstack/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/__init__.py#L45-L46

Added lines #L45 - L46 were not covered by tests


def get_tags() -> list[str]:
"""
Expand Down
12 changes: 5 additions & 7 deletions agentstack/_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
@classmethod
def from_tool_name(cls, name: str) -> 'ToolConfig':
path = TOOLS_DIR / name / TOOLS_CONFIG_FILENAME
if not os.path.exists(path): # TODO raise exceptions and handle message/exit in cli
print(term_color(f'No known agentstack tool: {name}', 'red'))
sys.exit(1)
if not os.path.exists(path):
raise ValidationError(f'No known agentstack tool: {name}')

Check warning on line 37 in agentstack/_tools/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/_tools/__init__.py#L37

Added line #L37 was not covered by tests
return cls.from_json(path)

@classmethod
Expand All @@ -44,11 +43,10 @@
try:
return cls(**data)
except pydantic.ValidationError as e:
# TODO raise exceptions and handle message/exit in cli
print(term_color(f"Error validating tool config JSON: \n{path}", 'red'))
error_str = "Error validating tool config:\n"

Check warning on line 46 in agentstack/_tools/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/_tools/__init__.py#L46

Added line #L46 was not covered by tests
for error in e.errors():
print(f"{' '.join([str(loc) for loc in error['loc']])}: {error['msg']}")
sys.exit(1)
error_str += f"{' '.join([str(loc) for loc in error['loc']])}: {error['msg']}\n"
raise ValidationError(f"Error loading tool from {path}.\n{error_str}")

Check warning on line 49 in agentstack/_tools/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentstack/_tools/__init__.py#L48-L49

Added lines #L48 - L49 were not covered by tests

@property
def type(self) -> type:
Expand Down
25 changes: 25 additions & 0 deletions agentstack/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from ruamel.yaml import YAML, YAMLError
from ruamel.yaml.scalarstring import FoldedScalarString
from agentstack import conf, log
from agentstack import frameworks
from agentstack.exceptions import ValidationError


AGENTS_FILENAME: Path = Path("src/config/agents.yaml")
AGENTS_PROMPT_TPL: str = "You are {role}. {backstory}\nYour personal goal is: {goal}"

yaml = YAML()
yaml.preserve_quotes = True # Preserve quotes in existing data
Expand Down Expand Up @@ -67,6 +69,23 @@ def __init__(self, name: str):
error_str += f"{' '.join([str(loc) for loc in error['loc']])}: {error['msg']}\n"
raise ValidationError(f"Error loading agent {name} from {filename}.\n{error_str}")

@property
def provider(self) -> str:
return frameworks.parse_llm(self.llm)[0]

@property
def model(self) -> str:
return frameworks.parse_llm(self.llm)[1]

@property
def prompt(self) -> str:
"""Concatenate the prompts for role, goal, and backstory."""
return AGENTS_PROMPT_TPL.format(**{
'role': self.role,
'goal': self.goal,
'backstory': self.backstory,
})

def model_dump(self, *args, **kwargs) -> dict:
dump = super().model_dump(*args, **kwargs)
dump.pop('name') # name is the key, so keep it out of the data
Expand Down Expand Up @@ -106,3 +125,9 @@ def get_all_agent_names() -> list[str]:

def get_all_agents() -> list[AgentConfig]:
return [AgentConfig(name) for name in get_all_agent_names()]


def get_agent(name: str) -> Optional[AgentConfig]:
"""Get an agent configuration by name."""
return AgentConfig(name)

7 changes: 5 additions & 2 deletions agentstack/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from .cli import init_project_builder, configure_default_model, export_template, welcome_message
from .cli import configure_default_model, welcome_message, get_validated_input
from .init import init_project
from .tools import list_tools, add_tool
from .wizard import run_wizard
from .run import run_project
from .tools import list_tools, add_tool
from .templates import insert_template, export_template

5 changes: 5 additions & 0 deletions agentstack/cli/agentstack_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
):
self.agents = []
self.tasks = []
self.graph = []

Check warning on line 61 in agentstack/cli/agentstack_data.py

View check run for this annotation

Codecov / codecov/patch

agentstack/cli/agentstack_data.py#L61

Added line #L61 was not covered by tests
self.inputs = {}
self.method = method
self.manager_agent = manager_agent
Expand All @@ -68,6 +69,9 @@
def add_task(self, task):
self.tasks.append(task)

def add_edge(self, edge):
self.graph.append(edge)

Check warning on line 73 in agentstack/cli/agentstack_data.py

View check run for this annotation

Codecov / codecov/patch

agentstack/cli/agentstack_data.py#L73

Added line #L73 was not covered by tests

def set_inputs(self, inputs):
self.inputs = inputs

Expand All @@ -77,6 +81,7 @@
'manager_agent': self.manager_agent,
'agents': self.agents,
'tasks': self.tasks,
'graph': self.graph,
'inputs': self.inputs,
}

Expand Down
Loading
Loading