Skip to content

Commit 6d0a34b

Browse files
authored
Merge pull request #271 from tcdent/framework-llamaindex
LlamaIndex
2 parents 11b3804 + 59f702a commit 6d0a34b

File tree

100 files changed

+2040
-1118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2040
-1118
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ ex/
175175
**/ex/
176176
cookiecutter.json
177177

178+
tests/tmp
179+
178180
examples/tests/
179181
examples/tests/**/*
180182

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
recursive-include agentstack/templates *
2+
recursive-include agentstack/frameworks/templates *
23
recursive-include agentstack/_tools *
34
include agentstack.json .env .env.example

agentstack/agents.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ruamel.yaml.scalarstring import FoldedScalarString
77
from agentstack import conf, log
88
from agentstack.exceptions import ValidationError
9+
from agentstack.providers import parse_provider_model
910

1011

1112
AGENTS_FILENAME: Path = Path("src/config/agents.yaml")
@@ -70,13 +71,13 @@ def __init__(self, name: str):
7071

7172
@property
7273
def provider(self) -> str:
73-
from agentstack import frameworks
74-
return frameworks.parse_llm(self.llm)[0]
74+
"""The LLM provider ie. 'openai' or 'openrouter'"""
75+
return parse_provider_model(self.llm)[0]
7576

7677
@property
7778
def model(self) -> str:
78-
from agentstack import frameworks
79-
return frameworks.parse_llm(self.llm)[1]
79+
"""The model name ie. 'gpt-4o'"""
80+
return parse_provider_model(self.llm)[1]
8081

8182
@property
8283
def prompt(self) -> str:

agentstack/cli/agentstack_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from datetime import datetime
33
from typing import Optional
44

5-
from agentstack.utils import clean_input, get_version
5+
from agentstack.utils import clean_input, get_version, snake_to_camel
66
from agentstack import log
77

88

@@ -11,6 +11,7 @@ def __init__(
1111
self,
1212
project_name: Optional[str] = None,
1313
project_slug: Optional[str] = None,
14+
class_name: Optional[str] = None,
1415
description: str = "",
1516
author_name: str = "",
1617
version: str = "",
@@ -21,6 +22,7 @@ def __init__(
2122
):
2223
self.project_name = clean_input(project_name) if project_name else "myagent"
2324
self.project_slug = clean_input(project_slug) if project_slug else self.project_name
25+
self.class_name = snake_to_camel(self.project_slug) if not class_name else class_name
2426
self.description = description
2527
self.author_name = author_name
2628
self.version = version
@@ -36,6 +38,7 @@ def to_dict(self):
3638
return {
3739
'project_name': self.project_name,
3840
'project_slug': self.project_slug,
41+
'class_name': self.class_name,
3942
'description': self.description,
4043
'author_name': self.author_name,
4144
'version': self.version,

agentstack/cli/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from agentstack import frameworks
1212
from agentstack import generation
1313
from agentstack import repo
14-
from agentstack.proj_templates import get_all_templates, TemplateConfig
14+
from agentstack.templates import get_all_templates, TemplateConfig
1515

1616
from agentstack.cli import welcome_message
1717
from agentstack.cli.wizard import run_wizard
@@ -80,7 +80,7 @@ def init_project(
8080
# TODO prevent the user from passing the --path argument to init
8181
if template and use_wizard:
8282
raise Exception("Template and wizard flags cannot be used together")
83-
83+
8484
require_uv()
8585
welcome_message()
8686

agentstack/cli/run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Optional, List
22
import sys
3+
import asyncio
34
import traceback
45
from pathlib import Path
56
import importlib.util
@@ -122,7 +123,13 @@ def run_project(command: str = 'run', cli_args: Optional[List[str]] = None):
122123
try:
123124
log.notify("Running your agent...")
124125
project_main = _import_project_module(conf.PATH)
125-
getattr(project_main, command)()
126+
main = getattr(project_main, command)
127+
128+
# handle both async and sync entrypoints
129+
if asyncio.iscoroutinefunction(main):
130+
asyncio.run(main())
131+
else:
132+
main()
126133
except ImportError as e:
127134
raise ValidationError(f"Failed to import AgentStack project at: {conf.PATH.absolute()}\n{e}")
128135
except Exception as e:

agentstack/cli/templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from agentstack.agents import get_all_agents
1111
from agentstack.tasks import get_all_tasks
1212
from agentstack import inputs
13-
from agentstack.proj_templates import CURRENT_VERSION, TemplateConfig
13+
from agentstack.templates import CURRENT_VERSION, TemplateConfig
1414
from agentstack.generation.files import ProjectFile
1515
from .agentstack_data import (
1616
FrameworkData,
@@ -52,7 +52,7 @@ def insert_template(name: str, template: TemplateConfig, framework: Optional[str
5252
framework=framework,
5353
)
5454

55-
template_path = get_package_path() / f'templates/{framework}'
55+
template_path = get_package_path() / f'frameworks/templates/{framework}'
5656
with open(f"{template_path}/cookiecutter.json", "w") as json_file:
5757
json.dump(cookiecutter_data.to_dict(), json_file)
5858
# TODO this should not be written to the package directory

agentstack/cli/wizard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from agentstack.cli import welcome_message, get_validated_input
1111
from agentstack.cli.cli import PREFERRED_MODELS
1212
from agentstack._tools import get_all_tools, get_all_tool_names
13-
from agentstack.proj_templates import TemplateConfig
13+
from agentstack.templates import TemplateConfig
1414

1515

1616
class WizardData(dict):

0 commit comments

Comments
 (0)