Agent

The Agent base class is the entry point of your project. You will subclass it when defining your own Agent, and will later Agent.register() Intent classes and other resources into it.

Once the Agent is defined, you will connect it to a cloud service with a Connector, to make prediction and trigger requests.

class Agent[source]

As the name suggests, Agent is the base class that models an Agent definition within the Intents framework.

Typically, you will define a single Agent class in your project, that could be as simple as this:

from intents import Agent

class MyAgent(Agent):
    """A little docstring for your Agent"""

You can optionally define the languages that you intend to support. Intents will look for language resources based on the language class variable:

class MyAgent(Agent):
    """A little docstring for your Agent"""
    languages = ["en", "it"]

Languages are values from LanguageCode. If omitted, Intents will discover language resources by itself.

You won’t do much more with your Agent class, other than registering intents and resources with Agent.register(), or passing it to a Connector to make predictions.

classmethod register(resource)[source]

Register the given resource in Agent. The resource could be:

  • An Intent

  • A module. In this case, the module is scanned (non recursively) for Intents, and each Intent is added individually

This is how you register a single intent:

from intents import Agent, Intent

class MyAgent(Agent):
    pass

@dataclass
class MyTestIntent(Intent):
    """A little docstring for my Intent..."""
    a_parameter: Sys.Date
    another_parameter: Sys.Person

MyAgent.register(MyTestIntent)

Alternatively, you can register a whole module containing Intents. This is how you register all the intents that are defined in the smalltalk module of example_agent:

from example_agent import smalltalk

class MyAgent(Agent):
    pass

MyAgent.register(smalltalk)

Note that together with each Intent, the Agent will register all of its linked properties and resources, such as parameters and Entities.

Parameters

resource (Union[Type[Intent], module]) – The resource to register (an Intent, or a module containing Intents)

class RegisteredParameter(metadata, used_in)[source]

Agents register intent parameters. If two intents declare the same parameter name, they must also declare the same type for it.

Parameters