mobilecoinofficial / forest

Enables a Forest of MobileCoin enabled SignalBots. Beta software, APIs may change!
MIT License
18 stars 13 forks source link

Add persistent synonyms with pdictng #134

Closed deepfates closed 2 years ago

deepfates commented 2 years ago

A bot with a thesaurus!

We want to be able to easily define synonyms for the various commands within bots: "hi" for "hello", "picture" for "imagine", etc.

I pulled the relevant logic out of https://github.com/mobilecoinofficial/forest/pull/127 and put it into SynonymBot class, using the powerful aPersistDict for stateful storage of synonyms.

Devs can still add lists of synonyms to methods in development, but now admins and users can adjust the bot's vocabulary directly in Signal. The interface is roughly based on the syntax of ln in the command line, like so:

link hello wazzup

SynonymBot has commands for linking, unlinking, listing synonyms, and more. It also has dialogue branches for various error states.

Still wondering:

Design/abstraction

Technical hurdles

NLP questions

Happy to accept feedback on any of the above, or anything I missed.

Sample dialogue

image

technillogue commented 2 years ago

maybe a decorator, like requires_admin / hide? at least fewer # type: hides

in the link it looks like a protocol might be the way to go, or a Command class that inherits from Callable but has more attributes....

mobfriend issue should be fixed, run pip install --upgrade prometheus_client prometheus_async locally; they added type hints in a new release

deepfates commented 2 years ago

Okay @technillogue , I pulled your fix from main (thx!) and then updated to a decorator and protocol. This fixes most of the issues with mypy, except for adding synonyms to an inherited method, because the signatures no longer match. Don't know how common this use case is though? Definitely reduced the amount of #type: ignore although not total LOC

itdaniher commented 2 years ago

this is so exciting.

itdaniher commented 2 years ago

I'm going to add the pdictng_readme.md document requested by @technillogue in #112