Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LlamaIndex #271

Merged
merged 14 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@
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 @@
):
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

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

View check run for this annotation

Codecov / codecov/patch

agentstack/cli/agentstack_data.py#L25

Added line #L25 was not covered by tests
self.description = description
self.author_name = author_name
self.version = version
Expand All @@ -36,6 +38,7 @@
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 @@
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())

Check warning on line 130 in agentstack/cli/run.py

View check run for this annotation

Codecov / codecov/patch

agentstack/cli/run.py#L130

Added line #L130 was not covered by tests
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 @@
framework=framework,
)

template_path = get_package_path() / f'templates/{framework}'
template_path = get_package_path() / f'frameworks/templates/{framework}'

Check warning on line 55 in agentstack/cli/templates.py

View check run for this annotation

Codecov / codecov/patch

agentstack/cli/templates.py#L55

Added line #L55 was not covered by tests
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