Skip to content

Commit

Permalink
Merge pull request #271 from tcdent/framework-llamaindex
Browse files Browse the repository at this point in the history
LlamaIndex
  • Loading branch information
bboynton97 authored Feb 7, 2025
2 parents 11b3804 + 59f702a commit 6d0a34b
Show file tree
Hide file tree
Showing 100 changed files with 2,040 additions and 1,118 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ ex/
**/ex/
cookiecutter.json

tests/tmp

examples/tests/
examples/tests/**/*

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
recursive-include agentstack/templates *
recursive-include agentstack/frameworks/templates *
recursive-include agentstack/_tools *
include agentstack.json .env .env.example
9 changes: 5 additions & 4 deletions agentstack/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ruamel.yaml.scalarstring import FoldedScalarString
from agentstack import conf, log
from agentstack.exceptions import ValidationError
from agentstack.providers import parse_provider_model


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

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

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

@property
def prompt(self) -> str:
Expand Down
5 changes: 4 additions & 1 deletion agentstack/cli/agentstack_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from typing import Optional

from agentstack.utils import clean_input, get_version
from agentstack.utils import clean_input, get_version, snake_to_camel
from agentstack import log


Expand All @@ -11,6 +11,7 @@ def __init__(
self,
project_name: Optional[str] = None,
project_slug: Optional[str] = None,
class_name: Optional[str] = None,
description: str = "",
author_name: str = "",
version: str = "",
Expand All @@ -21,6 +22,7 @@ def __init__(
):
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.class_name = snake_to_camel(self.project_slug) if not class_name else class_name
self.description = description
self.author_name = author_name
self.version = version
Expand All @@ -36,6 +38,7 @@ def to_dict(self):
return {
'project_name': self.project_name,
'project_slug': self.project_slug,
'class_name': self.class_name,
'description': self.description,
'author_name': self.author_name,
'version': self.version,
Expand Down
4 changes: 2 additions & 2 deletions agentstack/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from agentstack import frameworks
from agentstack import generation
from agentstack import repo
from agentstack.proj_templates import get_all_templates, TemplateConfig
from agentstack.templates import get_all_templates, TemplateConfig

from agentstack.cli import welcome_message
from agentstack.cli.wizard import run_wizard
Expand Down Expand Up @@ -80,7 +80,7 @@ def init_project(
# TODO prevent the user from passing the --path argument to init
if template and use_wizard:
raise Exception("Template and wizard flags cannot be used together")

require_uv()
welcome_message()

Expand Down
9 changes: 8 additions & 1 deletion agentstack/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional, List
import sys
import asyncio
import traceback
from pathlib import Path
import importlib.util
Expand Down Expand Up @@ -122,7 +123,13 @@ def run_project(command: str = 'run', cli_args: Optional[List[str]] = None):
try:
log.notify("Running your agent...")
project_main = _import_project_module(conf.PATH)
getattr(project_main, command)()
main = getattr(project_main, command)

# handle both async and sync entrypoints
if asyncio.iscoroutinefunction(main):
asyncio.run(main())
else:
main()
except ImportError as e:
raise ValidationError(f"Failed to import AgentStack project at: {conf.PATH.absolute()}\n{e}")
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions agentstack/cli/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from agentstack.agents import get_all_agents
from agentstack.tasks import get_all_tasks
from agentstack import inputs
from agentstack.proj_templates import CURRENT_VERSION, TemplateConfig
from agentstack.templates import CURRENT_VERSION, TemplateConfig
from agentstack.generation.files import ProjectFile
from .agentstack_data import (
FrameworkData,
Expand Down Expand Up @@ -52,7 +52,7 @@ def insert_template(name: str, template: TemplateConfig, framework: Optional[str
framework=framework,
)

template_path = get_package_path() / f'templates/{framework}'
template_path = get_package_path() / f'frameworks/templates/{framework}'
with open(f"{template_path}/cookiecutter.json", "w") as json_file:
json.dump(cookiecutter_data.to_dict(), json_file)
# TODO this should not be written to the package directory
Expand Down
2 changes: 1 addition & 1 deletion agentstack/cli/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from agentstack.cli import welcome_message, get_validated_input
from agentstack.cli.cli import PREFERRED_MODELS
from agentstack._tools import get_all_tools, get_all_tool_names
from agentstack.proj_templates import TemplateConfig
from agentstack.templates import TemplateConfig


class WizardData(dict):
Expand Down
Loading

0 comments on commit 6d0a34b

Please sign in to comment.