Skip to content

refactor: cleanup agent class objects#384

Merged
eob merged 7 commits into
mainfrom
doug/planner-to-agent
May 24, 2023
Merged

refactor: cleanup agent class objects#384
eob merged 7 commits into
mainfrom
doug/planner-to-agent

Conversation

@douglas-reid
Copy link
Copy Markdown
Contributor

This PR represents an attempt to cleanup, document, and rationalize the existing set of classes in agent hierarchy. I also wanted to remove as much vestigial and unused surface (primarily related to async execution) in an attempt to simplify and reduce surface area for implementors.

As part of this PR, I updated the example assistant to show how synchronous agent responses could be done using emitFns. This then led to an update of the REPL to allow flexible identification of AgentService methods. I think we need more thought there.

Because we've introduced an LLM class, I took the get_llm() method that created ad-hoc ones from context off of the context and added helpers to create contexts with LLM instances. This was an attempt to rationalize usage within Tools, etc. I'm open to other approaches there.

Copy link
Copy Markdown
Contributor

@eob eob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really solid. A few minor comments within


self.tags.append(tag)

def as_llm_input(self) -> str:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome idea

_LLM_KEY = "llm"


def with_llm(llm: LLM, context: Optional[AgentContext] = None) -> AgentContext:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the PR message it sounds like this felt mostly like an odd shim to write, but I actually think this style may prove super useful as a way to think....

If things like "Which LLM am I using" become dynamic settings of an instance-in-progress (e.g. 'let's try Cohere out'), then this kind of chaining could let us pile on user settings atop reasonable defaults in a pretty elegant way

while not isinstance(action, FinishAction):
action = self.take_action(context)

# TODO: logging?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out my weird, but I think workable (?), logging PR -- it proposes using structured logging to let us lift different views about agent/tool activity out of the standard logs.

pass


class Tool(BaseModel):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to include ABC since below has a @AbstractMethod?

"""Any direct output produced by the Tool."""


class AgentTool(Tool):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/readability - I was confused by AgentTool as a name.

I think the idea is that we want Tool to be an ABC, but we also want something that suffices as a short-cut for NoOp?

Maybe we just call it NoOpTool (if that's what it is)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or FinishTool

from steamship.agents.schema.tool import AgentContext, Tool


class Action(BaseModel):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important now, but thought pin to wonder if eventually input and output will benefit from being a proxy object which represents: "The ability to load blocks -- now or in the future". Such that both bindings can be a persistence-friendly future on blocks.

dkolas
dkolas previously approved these changes May 23, 2023
Copy link
Copy Markdown
Contributor

@dkolas dkolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are the hero we need, not the hero we deserve

"""Any direct output produced by the Tool."""


class AgentTool(Tool):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or FinishTool

@eob eob merged commit 735b323 into main May 24, 2023
@douglas-reid douglas-reid deleted the doug/planner-to-agent branch July 25, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants