Package: agency
SummaryAgency is a python library that provides anActor
modelframework for creating
agent-integrated systems.The library provides an easy to use API that enables you to connect agents with
traditional software systems in a flexible and scalable way, allowing you to
develop any architecture you need.Agency's goal is to enable developers to create custom agent-based applications
by providing a minimal foundation to both experiment and build upon. So if
you're looking to build a custom agent system of your own, Agency might be for
you.FeaturesEasy to use APIStraightforward class/method based agent and action definitionUp to date documentationandexamplesfor referencePerformance and ScalabilitySupports multiprocessing and multithreading for concurrencyAMQP support for networked agent systemsObservability and ControlAction and lifecycle callbacksAccess policies and permission callbacksDetailed loggingDemo application available atexamples/demoMultiple agent examples for experimentationTwo OpenAI agent examplesHuggingFace transformers agent exampleOperating system accessIncludes Gradio UIDocker configuration for reference and developmentAPI OverviewIn Agency, all entities are represented as instances of theAgentclass. This
includes all AI-driven agents, software interfaces, or human users that may
communicate as part of your application.All agents may expose "actions" that other agents can discover and invoke at run
time. An example of a simple agent could be:classCalculatorAgent(Agent):@actiondefadd(a,b):returna+bThis defines an agent with a single action:add. Other agents will be able
to call this method by sending a message to an instance ofCalculatorAgentand
specifying theaddaction. For example:other_agent.send({'to':'CalcAgent','action':{'name':'add','args':{'a':1,'b':2,}},})Actions may specify an access policy, allowing you to control access for safety.@action(access_policy=ACCESS_PERMITTED)# This allows the action at any timedefadd(a,b):...@action(access_policy=ACCESS_REQUESTED)# This requires review before the actiondefadd(a,b):...Agents may also define callbacks for various purposes:classCalculatorAgent(Agent):...defbefore_action(self,message:dict):"""Called before an action is attempted"""defafter_action(self,message:dict,return_value:str,error:str):"""Called after an action is attempted"""defafter_add(self):"""Called after the agent is added to a space and may begin communicating"""defbefore_remove(self):"""Called before the agent is removed from the space"""ASpaceis how you connect your agents together. An agent cannot communicate
with others until it is added to a commonSpace.There are two includedSpaceimplementations to choose from:LocalSpace- which connects agents within the same application.AMQPSpace- which connects agents across a network using an AMQP
server like RabbitMQ.Finally, here is a simple example of creating aLocalSpaceand adding two
agents to it.space=LocalSpace()space.add(CalculatorAgent,"CalcAgent")space.add(MyAgent,"MyAgent")# The agents above can now communicateThese are just the basic features that Agency provides. For more information
please seethe help site.InstallpipinstallagencyorpoetryaddagencyThe Demo ApplicationThe demo application is maintained as an experimental development environment
and a showcase for library features. It includes multiple agent examples which
may communicate with eachother and supports a "slash" syntax for invoking
actions as an agent yourself.To run the demo, please follow the directions atexamples/demo.The following is a screenshot of the Gradio UI that demonstrates the exampleOpenAIFunctionAgentfollowing orders and interacting with theHostagent.FAQHow does Agency compare to other agent frameworks?Though you could entirely create a simple agent using only the primitives in
Agency (seeexamples/demo/agents/), it is not
intended to be an all-inclusive LLM-oriented toolset like other libraries. For
example, it does not include support for constructing prompts or working with
vector databases. Implementation of agent behavior is left entirely up to you,
and you are free to use other libraries as needed for those purposes.Agency focuses on the concerns of communication, observation,
and scalability. The library strives to provide the operating
foundations of an agent system without imposing additional structure on you.The goal is to allow you to experiment and discover the right approaches and
technologies that work for your application. And once you've found an
implementation that works, you can scale it out to your needs.ContributingPlease do!If you're considering a contribution, please check out thecontributing
guide.Planned WorkSee the issues page.If you have any suggestions or otherwise, feel free to add an issue or open adiscussion.