Observed since 21 Oct, 09:30 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Modular composable chatbot development
Agent is a high-level toolkit for building chatbots using conversational components. Try Agent if you want to make your chatbot modular using composable components.
# optional: create a virtual environment
python3 -m venv myvenv
source myvenv/bin/activate
# install agt
pip3 install agt
You may want to install dependencies to connect to channels such as telegram and discord or share components on cocohub.
Available dependecies
Examples:
pip install agt[telegram]
# or for multiple dependecies
pip install agt[telegram,dsl]
Agent components are python coroutines (note the async def)
We take state as the first parameter - which is an object that allow us to interact with the environment the component/bot is running on
async def mybot(state):
# state.user_input() waits for the next user input
user_input = await state.user_input()
# state.say sends a response
await state.say(user_input)
Paste this code in a file called example.py
python3 -m agt example.mybot
Connecting to channels is easy and just requires using regular Agent components
Make sure to install agt with telegram support - pip install agt[telegram]
Create a new bot and get telegram token from Telegram botfather using this guide: https://core.telegram.org/bots#6-botfather
export TELEGRAM_TOKEN=<Your telegram bot token>
python3 -m agt.channels.telegram example.mybot
Make sure to install agt with discord support - pip install agt[discord]
Create a new bot account and get a token using this guide: https://discordpy.readthedocs.io/en/latest/discord.html
export DISCORD_KEY=<Your discord bot token>
python3 -m agt.channels.discord example.mybot
Make sure to install agt with microsoft bot framework support - pip install agt[msbf]
export MicrosoftAppId=<Your bot Microsft App Id>
export MicrosoftAppPassword=<Your bot Microsoft App Password>
python3 -m agt.channels.msbf example.mybot
Inside agt.nlu we have simple patterns to regex compiler to perform basic understanding tasks
Compile simple word patterns to regex
Some Examples:
intent = Intent(
Pattern("the", "boy", "ate", "an", "apple")
)
assert intent("the boy ate an apple") == True
assert intent("the boy ate an orange") == False
intent = Intent(
Pattern("the", "boy", "ate", "an", AnyWords(min=1, max=1))
)
assert intent("the boy ate an apple") == True
assert intent("the boy ate an orange") == True
intent = Intent(
Pattern("the", Words("boy", "girl"), "ate", "an", AnyWords(min=1, max=1))
)
assert intent("the boy ate an apple") == True
assert intent("the boy ate an orange") == True
assert intent("the girl ate an orange") == True
assert intent("the girl ate a banana") == False
intent = Intent(
Pattern("the", ("boy", "girl"), "ate", WordsRegex(r"an?"), AnyWords(min=1, max=1))
)
assert intent("the boy ate an apple") == True
assert intent("the boy ate an orange") == True
assert intent("the girl ate an orange") == True
assert intent("the girl ate a banana") == True
assert intent("a nice boy ate an apple") == False
intent = Intent(
Pattern(WILDCARD, Words("boy", "girl"), "ate", WordsRegex(r"an?"), AnyWords(min=1, max=1))
)
assert intent("a nice boy ate an apple") == True
Pattern takes sentence elements and translate each one to optmized regular expression.
Intent groups multiple patterns so if any of the patterns match the intent evals to True
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.6.4 | 28 Jun 2021 | 11 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 21 Oct, 09:30 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:5b2446037d8a815530d906ddefe19a3c1435c9bae8af7474d9b928da08c7808f