enrobie.plugins.ainswer package#
Submodules#
enrobie.plugins.ainswer.ainswer module#
- 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.
- 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.
enrobie.plugins.ainswer.common module#
- class enrobie.plugins.ainswer.common.AinswerDepends(plugin: AinswerPlugin, mitem: RobieMessage | None)[source]#
Bases:
objectDependencies related to operation with PydanticAI tools.
- plugin: AinswerPlugin#
- mitem: RobieMessage | None#
- class enrobie.plugins.ainswer.common.AinswerResponse[source]#
Bases:
BaseModelContains the response for question for the client type.
- class enrobie.plugins.ainswer.common.AinswerResponseDSC[source]#
Bases:
AinswerResponseContains the response for question for the client type.
- class enrobie.plugins.ainswer.common.AinswerResponseIRC[source]#
Bases:
AinswerResponseContains the response for question for the client type.
enrobie.plugins.ainswer.helpers module#
- 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#
- class enrobie.plugins.ainswer.history.SQLBase(**kwargs: Any)[source]#
Bases:
DeclarativeBaseSome additional class that SQLAlchemy requires to work.
- class enrobie.plugins.ainswer.history.AinswerHistoryTable(**kwargs)[source]#
Bases:
SQLBaseSchematic for the database operations using SQLAlchemy.
Note
Fields are not completely documented for this model.
- plugin#
- client#
- person#
- kind#
- author#
- anchor#
- message#
- ainswer#
- create#
- class enrobie.plugins.ainswer.history.AinswerHistoryRecord[source]#
Bases:
BaseModelContain the information regarding the chatting history.
- Parameters:
record – Record from the SQLAlchemy query routine.
kwargs – Keyword arguments passed for downstream.
Fields# Field
Type
Required
Default
Constraints
Yes
No
Nonemin_length=1
Yes
min_length=1
Yes
min_length=1
Yes
min_length=20, max_length=32
Literal[‘privmsg’, ‘chanmsg’]Yes
min_length=1
Yes
No
Nonemin_length=1
Yes
min_length=1
- plugin: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Plugin name where originated', metadata=[MinLen(min_length=1)])]#
- client: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Client name where originated', metadata=[MinLen(min_length=1)])]#
- person: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Person that author is matched', metadata=[MinLen(min_length=1)])]#
- kind: Annotated[Literal['privmsg', 'chanmsg'], FieldInfo(annotation=NoneType, required=True, description='What kind of original message', metadata=[MinLen(min_length=1)])]#
- author: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Nickname of message author', metadata=[MinLen(min_length=1)])]#
- anchor: Annotated[str, FieldInfo(annotation=NoneType, required=False, default=None, description='Channel or private context', metadata=[MinLen(min_length=1)])]#
- message: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Historical interaction content')]#
- class enrobie.plugins.ainswer.history.AinswerHistory(plugin: AinswerPlugin)[source]#
Bases:
objectStore the historical information for chat interactions.
- Parameters:
plugin – Plugin class instance for Chatting Robie.
- 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.
- 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.
- 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.
enrobie.plugins.ainswer.memory module#
- class enrobie.plugins.ainswer.memory.SQLBase(**kwargs: Any)[source]#
Bases:
DeclarativeBaseSome additional class that SQLAlchemy requires to work.
- class enrobie.plugins.ainswer.memory.AinswerMemoryTable(**kwargs)[source]#
Bases:
SQLBaseSchematic for the database operations using SQLAlchemy.
Note
Fields are not completely documented for this model.
- plugin#
- person#
- unique#
- message#
- create#
- class enrobie.plugins.ainswer.memory.AinswerMemoryRecord[source]#
Bases:
BaseModelContain the information regarding the chatting history.
- Parameters:
record – Record from the SQLAlchemy query routine.
kwargs – Keyword arguments passed for downstream.
Fields# Field
Type
Required
Default
Constraints
Yes
min_length=20, max_length=32
Yes
min_length=1, max_length=400
No
Nonemin_length=1
Yes
min_length=1
Yes
min_length=36, max_length=36
- plugin: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Plugin name where originated', metadata=[MinLen(min_length=1)])]#
- person: Annotated[str, FieldInfo(annotation=NoneType, required=False, default=None, description='Person that author is matched', 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.AinswerMemory(plugin: AinswerPlugin)[source]#
Bases:
objectStore the historical information for the person memory.
- Parameters:
plugin – Plugin class instance for Chatting Robie.
- insert(*, person: str, message: str) None[source]#
Insert the record into the historical person memorables.
- expunge(person: str) None[source]#
Remove the expired historical person memorable records.
- Parameters:
person – Unique identifier for the person object.
- 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.
- 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.
enrobie.plugins.ainswer.models module#
- class enrobie.plugins.ainswer.models.AinswerModels(plugin: AinswerPlugin)[source]#
Bases:
objectReturn 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.
- classmethod settings() Type[ModelSettings][source]#
Return the class object that was imported within method.
- property anthropic: AnthropicModel#
Return the class object that was imported within method.
- property openai: OpenAIChatModel#
Return the class object that was imported within method.
- property ollama: OpenAIChatModel#
Return the class object that was imported within method.
enrobie.plugins.ainswer.params module#
- class enrobie.plugins.ainswer.params.AinswerPluginAinswerParams[source]#
Bases:
RobieParamsModelProcess and validate the Robie configuration parameters.
Fields# Field
Type
Required
Default
Constraints
No
Nonemin_length=1
Yes
min_length=1
Literal[‘anthropic’, ‘openai’, ‘ollama’]Yes
No
Nonemin_length=1
No
(15, 30)No
30ge=1, le=300
- origin: Annotated[Literal['anthropic', 'openai', 'ollama'], FieldInfo(annotation=NoneType, required=True, description='Which platform hosts the model')]#
- model: Annotated[str, FieldInfo(annotation=NoneType, required=True, description='Platform model that will be used', metadata=[MinLen(min_length=1)])]#
- baseurl: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='URL for connecting to platform', metadata=[MinLen(min_length=1)])]#
- secret: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Secret for platform authorization', metadata=[MinLen(min_length=1)])]#
- class enrobie.plugins.ainswer.params.AinswerPluginPromptClientParams[source]#
Bases:
RobieParamsModelProcess and validate the Robie configuration parameters.
Fields# Field
Type
Required
Default
Constraints
No
'In 1875 characters or less, answer the user question. Markdown is encouraged.'min_length=1
No
'In 325 characters or less, answer the user question. Do not use markdown. Do not use colors.'min_length=1
No
'In 1875 characters or less, answer the user question. Markdown is encouraged.'min_length=1
- dsc: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='In 1875 characters or less, answer the user question. Markdown is encouraged.', description='Supplement the system prompt', metadata=[MinLen(min_length=1)])]#
- class enrobie.plugins.ainswer.params.AinswerPluginPromptParams[source]#
Bases:
RobieParamsModelProcess and validate the Robie configuration parameters.
Fields# Field
Type
Required
Default
Constraints
No
factory
No
Nonemin_length=1
No
Nonemin_length=1
No
['If you believe that you are being abused by the user asking the question.']min_length=1
No
'You are a helpful chatbot assistant named Robie. You were built by Robert, at the Enasis Network.'min_length=1
- 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)])]#
- client: Annotated[AinswerPluginPromptClientParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptClientParams, description='Additional chat platform prompt')]#
- header: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Optional header before question', metadata=[MinLen(min_length=1)])]#
- class enrobie.plugins.ainswer.params.AinswerPluginParams[source]#
Bases:
RobiePluginParamsProcess and validate the Robie configuration parameters.
Fields# Field
Type
Required
Default
Constraints
Yes
Yes
min_length=1
No
'sqlite:///:memory:'min_length=1
enableNo
FalseNo
10ge=1, le=1000
locateNo
Nonemin_length=1
No
Nonemin_length=1
No
10ge=1, le=1000
No
Nonemin_length=1
No
factory
No
factory
trustedNo
Nonemin_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)])]#
- memories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per person', metadata=[Ge(ge=1), Le(le=1000)])]#
- clients: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, description='List of clients to enable plugin', metadata=[MinLen(min_length=1)])]#
- ainswer: Annotated[AinswerPluginAinswerParams, FieldInfo(annotation=NoneType, required=True, description='Parameters for the AI platforms')]#
- prompt: Annotated[AinswerPluginPromptParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptParams, description='Override the agent system prompt')]#
- plugins: Annotated[list[str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='List of plugins to load tools', metadata=[MinLen(min_length=1)])]#
- logger: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Logger for including recents', metadata=[MinLen(min_length=1)])]#
- status: Annotated[StatusPluginIconParams, FieldInfo(annotation=NoneType, required=False, default_factory=StatusPluginIconParams, description='Icon used per chat platform')]#
enrobie.plugins.ainswer.plugin module#
- class enrobie.plugins.ainswer.plugin.AinswerPlugin(robie: Robie, name: str, params: RobieChildParams)[source]#
Bases:
RobiePluginIntegrate with the Robie routine and perform operations.
Note
This plugin allows for interacting with an LLM model.
- classmethod schema() Type[AinswerPluginParams][source]#
Return the configuration parameters relevant for class.
- Returns:
Configuration parameters relevant for class.
- property params: AinswerPluginParams#
Return the Pydantic model containing the configuration.
- Returns:
Pydantic model containing the configuration.
- property models: AinswerModels#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property toolset: AinswerToolset#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property question: AinswerQuestion#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- 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 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.
enrobie.plugins.ainswer.question module#
- class enrobie.plugins.ainswer.question.AinswerQuestion(plugin: AinswerPlugin)[source]#
Bases:
objectConstruct 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#
- class enrobie.plugins.ainswer.toolset.AinswerToolset(plugin: AinswerPlugin)[source]#
Bases:
objectEnumerate the plugins and return those that are related.
- Parameters:
plugin – Plugin class instance for Chatting Robie.
Module contents#
- class enrobie.plugins.ainswer.AinswerPlugin(robie: Robie, name: str, params: RobieChildParams)[source]#
Bases:
RobiePluginIntegrate with the Robie routine and perform operations.
Note
This plugin allows for interacting with an LLM model.
- classmethod schema() Type[AinswerPluginParams][source]#
Return the configuration parameters relevant for class.
- Returns:
Configuration parameters relevant for class.
- property params: AinswerPluginParams#
Return the Pydantic model containing the configuration.
- Returns:
Pydantic model containing the configuration.
- property models: AinswerModels#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property toolset: AinswerToolset#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property question: AinswerQuestion#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- 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 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.
- class enrobie.plugins.ainswer.AinswerPluginParams[source]#
Bases:
RobiePluginParamsProcess and validate the Robie configuration parameters.
Fields# Field
Type
Required
Default
Constraints
Yes
Yes
min_length=1
No
'sqlite:///:memory:'min_length=1
enableNo
FalseNo
10ge=1, le=1000
locateNo
Nonemin_length=1
No
Nonemin_length=1
No
10ge=1, le=1000
No
Nonemin_length=1
No
factory
No
factory
trustedNo
Nonemin_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)])]#
- memories: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=10, description='Number of messages per person', metadata=[Ge(ge=1), Le(le=1000)])]#
- clients: Annotated[list[str], FieldInfo(annotation=NoneType, required=True, description='List of clients to enable plugin', metadata=[MinLen(min_length=1)])]#
- ainswer: Annotated[AinswerPluginAinswerParams, FieldInfo(annotation=NoneType, required=True, description='Parameters for the AI platforms')]#
- prompt: Annotated[AinswerPluginPromptParams, FieldInfo(annotation=NoneType, required=False, default_factory=AinswerPluginPromptParams, description='Override the agent system prompt')]#
- plugins: Annotated[list[str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='List of plugins to load tools', metadata=[MinLen(min_length=1)])]#
- logger: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Logger for including recents', metadata=[MinLen(min_length=1)])]#
- status: Annotated[StatusPluginIconParams, FieldInfo(annotation=NoneType, required=False, default_factory=StatusPluginIconParams, description='Icon used per chat platform')]#
- class enrobie.plugins.ainswer.AinswerDepends(plugin: AinswerPlugin, mitem: RobieMessage | None)[source]#
Bases:
objectDependencies related to operation with PydanticAI tools.
- plugin: AinswerPlugin#
- mitem: RobieMessage | None#