enrobie.plugins.ainswer package#

Subpackages#

Submodules#

enrobie.plugins.ainswer.ainswer module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

async enrobie.plugins.ainswer.ainswer.ainswer_memory_delete(context: RunContext[AinswerDepends], unique: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Unique identifier for memory', metadata=[MinLen(min_length=36), MaxLen(max_length=36)])]) None[source]#

Delete the record from the historical person memorables.

Note

This tool will allow for deleting the memories for the provided username, also known as a Robie person.

async enrobie.plugins.ainswer.ainswer.ainswer_memory_insert(context: RunContext[AinswerDepends], message: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Historical person memorable', metadata=[MinLen(min_length=1), MaxLen(max_length=400)])]) None[source]#

Insert the memory into the historical person memorables.

Do not add memories of previous questions or discussion. Do not add new memories without confirmation as there is limited storage that the person may have for memorables. Only add the memory one time after ensuring it does not already exist, using the ainswer_memory_records tool. Always confirm with the person before inserting message. Be very cautious and conservative with use of this tool, the bot is configured by default to remove older entries once the limit for the person memories has been reached!

Note

This tool will allow for inserting new memories for the provided username, also known as a Robie person.

async enrobie.plugins.ainswer.ainswer.ainswer_memory_records(context: RunContext[AinswerDepends]) list[AinswerMemoryRecord] | None[source]#

Return the historical records for the person memorables.

Note

This tool will return historical memorable items for the provided username, also known as a Robie person.

enrobie.plugins.ainswer.common module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.common.AinswerDepends(plugin: AinswerPlugin, mitem: RobieMessage | None)[source]#

Bases: object

Dependencies related to operation with PydanticAI tools.

mitem: RobieMessage | None#
plugin: AinswerPlugin#
class enrobie.plugins.ainswer.common.AinswerResponse(*, text: str)[source]#

Bases: BaseModel

Contains the response for question for the client type.

model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

text: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Simple and concise format.')]#
class enrobie.plugins.ainswer.common.AinswerResponseDSC(*, text: Annotated[str, MaxLen(max_length=1900)])[source]#

Bases: AinswerResponse

Contains the response for question for the client type.

model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

text: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Format intended for Discord.', metadata=[MaxLen(max_length=1900)])]#
class enrobie.plugins.ainswer.common.AinswerResponseIRC(*, text: Annotated[str, MaxLen(max_length=350)])[source]#

Bases: AinswerResponse

Contains the response for question for the client type.

model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

text: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Format intended for IRCv2.', metadata=[MaxLen(max_length=350)])]#
class enrobie.plugins.ainswer.common.AinswerResponseMTM(*, text: Annotated[str, MaxLen(max_length=1900)])[source]#

Bases: AinswerResponse

Contains the response for question for the client type.

model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

text: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Format intended for Mattermost.', metadata=[MaxLen(max_length=1900)])]#

enrobie.plugins.ainswer.helpers module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

enrobie.plugins.ainswer.helpers.composedsc(plugin: AinswerPlugin, mitem: RobieMessage) None[source]#

Construct and format message for related chat platform.

Parameters:
  • plugin – Plugin class instance for Chatting Robie.

  • mitem – Item containing information for operation.

enrobie.plugins.ainswer.helpers.composeirc(plugin: AinswerPlugin, mitem: RobieMessage) None[source]#

Construct and format message for related chat platform.

Parameters:
  • plugin – Plugin class instance for Chatting Robie.

  • mitem – Item containing information for operation.

enrobie.plugins.ainswer.helpers.composemtm(plugin: AinswerPlugin, mitem: RobieMessage) None[source]#

Construct and format message for related chat platform.

Parameters:
  • plugin – Plugin class instance for Chatting Robie.

  • mitem – Item containing information for operation.

enrobie.plugins.ainswer.history module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.history.AinswerHistory(plugin: AinswerPlugin)[source]#

Bases: object

Store the historical information for chat interactions.

Parameters:

plugin – Plugin class instance for Chatting Robie.

expunge(client: str, kind: str, anchor: str) None[source]#

Remove the expired historical chat interaction records.

Parameters:
  • client – Unique identifier for the client object.

  • kind – What kind of Robie message we dealing with.

  • anchor – Unique identifier for the chat context.

insert(*, client: str, person: str | None, kind: str, author: str, anchor: str, message: str, ainswer: str) None[source]#

Insert the record into the historical chat interactions.

process(mitem: RobieMessage, ainswer: str) None[source]#

Insert the record into the historical chat interactions.

Parameters:
  • mitem – Item containing information for operation.

  • ainswer – Response from LLM relevant to question.

records(mitem: RobieMessage, limit: int | None = None) list[AinswerHistoryRecord][source]#

Return the historical records for the chat interactions.

Parameters:
  • mitem – Item containing information for operation.

  • limit – Optionally restrict the records returned.

Returns:

Historical records for the chat interactions.

search(limit: int | None = None, *, client: str | None = None, person: str | None = None, kind: str | None = None, author: str | None = None, anchor: str | None = None) list[AinswerHistoryRecord][source]#

Return the historical records for the chat interactions.

Parameters:

limit – Optionally restrict the records returned.

Returns:

Historical records for the chat interactions.

class enrobie.plugins.ainswer.history.AinswerHistoryRecord(record: AinswerHistoryTable | None = None, *, plugin: Annotated[str, MinLen(min_length=1)], client: Annotated[str, MinLen(min_length=1)], person: Annotated[str | None, MinLen(min_length=1)] = None, kind: Annotated[Literal['privmsg', 'chanmsg'], MinLen(min_length=1)], author: Annotated[str, MinLen(min_length=1)], anchor: Annotated[str, MinLen(min_length=1)] = None, message: str, ainswer: str, create: Annotated[str, MinLen(min_length=20), MaxLen(max_length=32)])[source]#

Bases: BaseModel

Contain the information regarding the chatting history.

Parameters:
  • record – Record from the SQLAlchemy query routine.

  • kwargs – Keyword arguments passed for downstream.

ainswer: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Historical interaction content')]#
anchor: Annotated[str, FieldInfo(annotation=NoneType, required=False, default=None, description='Channel or private context', metadata=[MinLen(min_length=1)])]#
author: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Nickname of message author', metadata=[MinLen(min_length=1)])]#
client: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Client name where originated', metadata=[MinLen(min_length=1)])]#
create: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='When the record was created', metadata=[MinLen(min_length=20), MaxLen(max_length=32)])]#
kind: Annotated[Literal['privmsg', 'chanmsg'], FieldInfo(annotation=NoneType, required=True, description='What kind of original message', metadata=[MinLen(min_length=1)])]#
message: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Historical interaction content')]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

person: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Person that author is matched', metadata=[MinLen(min_length=1)])]#
plugin: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Plugin name where originated', metadata=[MinLen(min_length=1)])]#
class enrobie.plugins.ainswer.history.AinswerHistoryTable(**kwargs)[source]#

Bases: SQLBase

Schematic for the database operations using SQLAlchemy.

Note

Fields are not completely documented for this model.

ainswer#
anchor#
author#
client#
create#
kind#
message#
person#
plugin#
class enrobie.plugins.ainswer.history.SQLBase(**kwargs: Any)[source]#

Bases: DeclarativeBase

Some additional class that SQLAlchemy requires to work.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[registry] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

enrobie.plugins.ainswer.memory module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.memory.AinswerMemory(plugin: AinswerPlugin)[source]#

Bases: object

Store the historical information for the person memory.

Parameters:

plugin – Plugin class instance for Chatting Robie.

delete(person: str, unique: str) None[source]#

Delete the record from the historical person memorables.

Parameters:
  • person – Unique identifier for the person object.

  • unique – Unique identifier for person memorable.

expunge(person: str) None[source]#

Remove the expired historical person memorable records.

Parameters:

person – Unique identifier for the person object.

insert(*, person: str, message: str) None[source]#

Insert the record into the historical person memorables.

records(mitem: RobieMessage) list[AinswerMemoryRecord][source]#

Return the historical records for the person memorables.

Parameters:

mitem – Item containing information for operation.

Returns:

Historical records for the person memorables.

search(*, person: str | None = None, unique: str | None = None) list[AinswerMemoryRecord][source]#

Return the historical records for the person memorables.

Returns:

Historical records for the person memorables.

class enrobie.plugins.ainswer.memory.AinswerMemoryRecord(record: AinswerMemoryTable | None = None, *, plugin: Annotated[str, MinLen(min_length=1)], person: Annotated[str, MinLen(min_length=1)] = None, unique: Annotated[str, MinLen(min_length=36), MaxLen(max_length=36)], message: Annotated[str, MinLen(min_length=1), MaxLen(max_length=400)], create: Annotated[str, MinLen(min_length=20), MaxLen(max_length=32)])[source]#

Bases: BaseModel

Contain the information regarding the chatting history.

Parameters:
  • record – Record from the SQLAlchemy query routine.

  • kwargs – Keyword arguments passed for downstream.

create: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='When the record was created', metadata=[MinLen(min_length=20), MaxLen(max_length=32)])]#
message: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Historical person memorable', metadata=[MinLen(min_length=1), MaxLen(max_length=400)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

person: Annotated[str, FieldInfo(annotation=NoneType, required=False, default=None, description='Person that author is matched', metadata=[MinLen(min_length=1)])]#
plugin: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Plugin name where originated', metadata=[MinLen(min_length=1)])]#
unique: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Unique identifier for memory', metadata=[MinLen(min_length=36), MaxLen(max_length=36)])]#
class enrobie.plugins.ainswer.memory.AinswerMemoryTable(**kwargs)[source]#

Bases: SQLBase

Schematic for the database operations using SQLAlchemy.

Note

Fields are not completely documented for this model.

create#
message#
person#
plugin#
unique#
class enrobie.plugins.ainswer.memory.SQLBase(**kwargs: Any)[source]#

Bases: DeclarativeBase

Some additional class that SQLAlchemy requires to work.

metadata: ClassVar[MetaData] = MetaData()#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[registry] = <sqlalchemy.orm.decl_api.registry object>#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

enrobie.plugins.ainswer.models module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.models.AinswerModels(plugin: AinswerPlugin)[source]#

Bases: object

Return the class object that was imported within method.

Parameters:

plugin – Plugin class instance for Chatting Robie.

classmethod agent() Type[Agent[AinswerDepends, str]][source]#

Return the class object that was imported within method.

property anthropic: AnthropicModel#

Return the class object that was imported within method.

property openai: OpenAIModel#

Return the class object that was imported within method.

classmethod settings() Type[ModelSettings][source]#

Return the class object that was imported within method.

enrobie.plugins.ainswer.params module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.params.AinswerPluginAinswerParams(*, origin: Literal['anthropic', 'openai'], model: Annotated[str, MinLen(min_length=1)], secret: Annotated[str, MinLen(min_length=1)], timeout: Annotated[int, Ge(ge=1), Le(le=300)] = 30, sleep: tuple[int, int] = (15, 30))[source]#

Bases: RobieParamsModel

Process and validate the Robie configuration parameters.

model: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Platform model that will be used', metadata=[MinLen(min_length=1)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

origin: Annotated[Literal['anthropic', 'openai'], FieldInfo(annotation=NoneType, required=True, description='Which platform hosts the model')]#
secret: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Model in platform that is used', metadata=[MinLen(min_length=1)])]#
sleep: Annotated[tuple[int, int], FieldInfo(annotation=NoneType, required=False, default=15, 30, description='Time to wait before the request')]#
timeout: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=30, description='Time to wait during the request', metadata=[Ge(ge=1), Le(le=300)])]#
class enrobie.plugins.ainswer.params.AinswerPluginParams(_parse: ~typing.Callable[[...], ~typing.Any] | None = None, *, enable: bool = False, locate: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, trusted: ~typing.Annotated[list[str] | None, ~annotated_types.MinLen(min_length=1)] = None, database: ~typing.Annotated[str, ~annotated_types.MinLen(min_length=1)] = 'sqlite:///:memory:', histories: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=1000)] = 10, memories: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=1000)] = 10, clients: ~typing.Annotated[list[str], ~annotated_types.MinLen(min_length=1)], ainswer: ~enrobie.plugins.ainswer.params.AinswerPluginAinswerParams, prompt: ~enrobie.plugins.ainswer.params.AinswerPluginPromptParams = <factory>, plugins: ~typing.Annotated[list[str] | None, ~annotated_types.MinLen(min_length=1)] = None, logger: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, status: ~enrobie.plugins.status.params.StatusPluginIconParams = <factory>)[source]#

Bases: RobiePluginParams

Process and validate the Robie configuration parameters.

ainswer: Annotated[AinswerPluginAinswerParams, FieldInfo(annotation=NoneType, required=True, description='Parameters for the AI platforms')]#
clients: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, description='List of clients to enable plugin', metadata=[MinLen(min_length=1)])]#
database: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='sqlite:///:memory:', description='Database connection string', metadata=[MinLen(min_length=1)])]#
histories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per anchor', metadata=[Ge(ge=1), Le(le=1000)])]#
logger: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Logger for including recents', metadata=[MinLen(min_length=1)])]#
memories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per person', metadata=[Ge(ge=1), Le(le=1000)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

plugins: Annotated[list[str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='List of plugins to load tools', metadata=[MinLen(min_length=1)])]#
prompt: Annotated[AinswerPluginPromptParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptParams, description='Override the agent system prompt')]#
status: Annotated[StatusPluginIconParams, FieldInfo(annotation=NoneType, required=False, default_factory=StatusPluginIconParams, description='Icon used per chat platform')]#
class enrobie.plugins.ainswer.params.AinswerPluginPromptClientParams(*, dsc: Annotated[str, MinLen(min_length=1)] = 'In 1875 characters or less, answer the user question. Format for Discord. Markdown is encouraged.', irc: Annotated[str, MinLen(min_length=1)] = 'In 325 characters or less, answer the user question. Format for IRCv2. Do not use markdown. Do not use colors.', mtm: Annotated[str, MinLen(min_length=1)] = 'In 1875 characters or less, answer the user question. Format for Mattermost. Markdown is encouraged.')[source]#

Bases: RobieParamsModel

Process and validate the Robie configuration parameters.

dsc: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='In 1875 characters or less, answer the user question. Format for Discord. Markdown is encouraged.', description='Supplement the system prompt', metadata=[MinLen(min_length=1)])]#
irc: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='In 325 characters or less, answer the user question. Format for IRCv2. Do not use markdown. Do not use colors.', description='Supplement the system prompt', metadata=[MinLen(min_length=1)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mtm: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='In 1875 characters or less, answer the user question. Format for Mattermost. Markdown is encouraged.', description='Supplement the system prompt', metadata=[MinLen(min_length=1)])]#
class enrobie.plugins.ainswer.params.AinswerPluginPromptParams(_parse: ~typing.Callable[[...], ~typing.Any] | None = None, *, system: ~typing.Annotated[str, ~annotated_types.MinLen(min_length=1)] = 'You are a helpful chatbot assistant named Robie. You were built by Robert, at the Enasis Network.', client: ~enrobie.plugins.ainswer.params.AinswerPluginPromptClientParams = <factory>, header: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, footer: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, ignore: ~typing.Annotated[list[str], ~annotated_types.MinLen(min_length=1)] = ['If you believe that you are being abused by the user asking the question.'])[source]#

Bases: RobieParamsModel

Process and validate the Robie configuration parameters.

client: Annotated[AinswerPluginPromptClientParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptClientParams, description='Additional chat platform prompt')]#
footer: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Optional footer after question', metadata=[MinLen(min_length=1)])]#
header: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Optional header before question', metadata=[MinLen(min_length=1)])]#
ignore: Annotated[list[str], FieldInfo(annotation=NoneType, required=False, default=['If you believe that you are being abused by the user asking the question.'], description='Reasons for LLM to decline response', metadata=[MinLen(min_length=1)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

system: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='You are a helpful chatbot assistant named Robie. You were built by Robert, at the Enasis Network.', description='Override the agent system prompt', metadata=[MinLen(min_length=1)])]#

enrobie.plugins.ainswer.plugin module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.plugin.AinswerPlugin(robie: Robie, name: str, params: RobieChildParams)[source]#

Bases: RobiePlugin

Integrate with the Robie routine and perform operations.

Note

This plugin allows for interacting with an LLM model.

property agent: Agent[AinswerDepends, str]#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

ainswer(mitem: RobieMessage, prompt: str, respond: Type[AinswerResponse]) str[source]#

Submit the question to the LLM and return the response.

Parameters:
  • mitem – Item containing information for operation.

  • prompt – Additional prompt insert before question.

  • respond – Model to describe the expected response.

Returns:

Response adhering to provided specifications.

property history: AinswerHistory#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property memory: AinswerMemory#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property models: AinswerModels#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

operate() None[source]#

Perform the operation related to Robie service threads.

property params: AinswerPluginParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

printer(source: dict[str, Any], color: int = 6) None[source]#

Print the contents for the object within Robie instance.

Parameters:
  • source – Content which will be shown after header.

  • color – Override the color used for box character.

property question: AinswerQuestion#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

classmethod schema() Type[AinswerPluginParams][source]#

Return the configuration parameters relevant for class.

Returns:

Configuration parameters relevant for class.

property toolset: AinswerToolset#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

validate() None[source]#

Perform advanced validation on the parameters provided.

enrobie.plugins.ainswer.question module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.question.AinswerQuestion(plugin: AinswerPlugin)[source]#

Bases: object

Construct prompt and allow for interacting with the LLM.

Parameters:

plugin – Plugin class instance for Chatting Robie.

prompt(mitem: RobieMessage, prompt: str) str[source]#

Return the message prefixed with runtime prompt values.

Parameters:
  • mitem – Item containing information for operation.

  • prompt – Additional prompt insert before question.

Returns:

Message prefixed with runtime prompt values.

submit(prompt: str, respond: Type[AinswerResponse], mitem: RobieMessage | None = None) AinswerResponse[source]#

Submit the question to the LLM and return the response.

Parameters:
  • prompt – Question that will be asked of the LLM.

  • respond – Model to describe the expected response.

  • mitem – Item containing information for operation.

Returns:

Response adhering to provided specifications.

enrobie.plugins.ainswer.toolset module#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.toolset.AinswerToolset(plugin: AinswerPlugin)[source]#

Bases: object

Enumerate the plugins and return those that are related.

Parameters:

plugin – Plugin class instance for Chatting Robie.

property toolset: list[Callable[[...], Any]]#

Return the related tools that were found in the plugins.

Returns:

Related tools that were found in the plugins.

Module contents#

Functions and routines associated with Enasis Network Chatting Robie.

This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.

class enrobie.plugins.ainswer.AinswerDepends(plugin: AinswerPlugin, mitem: RobieMessage | None)[source]#

Bases: object

Dependencies related to operation with PydanticAI tools.

mitem: RobieMessage | None#
plugin: AinswerPlugin#
class enrobie.plugins.ainswer.AinswerPlugin(robie: Robie, name: str, params: RobieChildParams)[source]#

Bases: RobiePlugin

Integrate with the Robie routine and perform operations.

Note

This plugin allows for interacting with an LLM model.

property agent: Agent[AinswerDepends, str]#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

ainswer(mitem: RobieMessage, prompt: str, respond: Type[AinswerResponse]) str[source]#

Submit the question to the LLM and return the response.

Parameters:
  • mitem – Item containing information for operation.

  • prompt – Additional prompt insert before question.

  • respond – Model to describe the expected response.

Returns:

Response adhering to provided specifications.

property history: AinswerHistory#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property memory: AinswerMemory#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property models: AinswerModels#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

operate() None[source]#

Perform the operation related to Robie service threads.

property params: AinswerPluginParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

printer(source: dict[str, Any], color: int = 6) None[source]#

Print the contents for the object within Robie instance.

Parameters:
  • source – Content which will be shown after header.

  • color – Override the color used for box character.

property question: AinswerQuestion#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

classmethod schema() Type[AinswerPluginParams][source]#

Return the configuration parameters relevant for class.

Returns:

Configuration parameters relevant for class.

property toolset: AinswerToolset#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

validate() None[source]#

Perform advanced validation on the parameters provided.

class enrobie.plugins.ainswer.AinswerPluginParams(_parse: ~typing.Callable[[...], ~typing.Any] | None = None, *, enable: bool = False, locate: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, trusted: ~typing.Annotated[list[str] | None, ~annotated_types.MinLen(min_length=1)] = None, database: ~typing.Annotated[str, ~annotated_types.MinLen(min_length=1)] = 'sqlite:///:memory:', histories: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=1000)] = 10, memories: ~typing.Annotated[int, ~annotated_types.Ge(ge=1), ~annotated_types.Le(le=1000)] = 10, clients: ~typing.Annotated[list[str], ~annotated_types.MinLen(min_length=1)], ainswer: ~enrobie.plugins.ainswer.params.AinswerPluginAinswerParams, prompt: ~enrobie.plugins.ainswer.params.AinswerPluginPromptParams = <factory>, plugins: ~typing.Annotated[list[str] | None, ~annotated_types.MinLen(min_length=1)] = None, logger: ~typing.Annotated[str | None, ~annotated_types.MinLen(min_length=1)] = None, status: ~enrobie.plugins.status.params.StatusPluginIconParams = <factory>)[source]#

Bases: RobiePluginParams

Process and validate the Robie configuration parameters.

ainswer: Annotated[AinswerPluginAinswerParams, FieldInfo(annotation=NoneType, required=True, description='Parameters for the AI platforms')]#
clients: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, description='List of clients to enable plugin', metadata=[MinLen(min_length=1)])]#
database: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='sqlite:///:memory:', description='Database connection string', metadata=[MinLen(min_length=1)])]#
histories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per anchor', metadata=[Ge(ge=1), Le(le=1000)])]#
logger: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Logger for including recents', metadata=[MinLen(min_length=1)])]#
memories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per person', metadata=[Ge(ge=1), Le(le=1000)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

plugins: Annotated[list[str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='List of plugins to load tools', metadata=[MinLen(min_length=1)])]#
prompt: Annotated[AinswerPluginPromptParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptParams, description='Override the agent system prompt')]#
status: Annotated[StatusPluginIconParams, FieldInfo(annotation=NoneType, required=False, default_factory=StatusPluginIconParams, description='Icon used per chat platform')]#