Configuration properties#
An agent needs some parameters to be set to properly work. In this section, you will find all of them, and we will explain you how to load them in the agent.
An agent Property has a name, a type and a default value
(for when the property is not defined by the agent developer).
Property names follow flattened dot notation from the YAML hierarchy, e.g. platforms.websocket.host.
Loading properties#
You can define your agent properties in 2 different ways:
- Using a configuration `.yaml` file: It is a file containing all the agent properties. Let’s see an example
config.yamlfile:
agent:
check_transitions_delay: 5
nlp:
language: en
region: US
timezone: Europe/Madrid
pre_processing: True
intent_threshold: 0.4
huggingface:
token: YOUR-TOKEN
openai:
api_key: YOUR-API-KEY
replicate:
api_key: YOUR-API-KEY
platforms:
websocket:
host: localhost
port: 8765
# origins:
# - "https://example.com"
# - "https://app.example.com"
streamlit:
host: localhost
port: 5000
chat:
size: 16
font: sans
line_spacing: 1.5
alignment: left
color: inherit
contrast: medium
telegram:
token: YOUR-BOT-TOKEN
github:
personal_token: YOUR-PERSONAL-TOKEN
webhook_token: YOUR-WEBHOOK-TOKEN
webhook_port: 8901
gitlab:
personal_token: YOUR-PERSONAL-TOKEN
webhook_token: YOUR-WEBHOOK-TOKEN
webhook_port: 8901
a2a:
port: 8000
db:
monitoring:
enabled: True
dialect: postgresql
host: YOUR-DB-HOST
port: 5432
database: YOUR-DB-NAME
username: YOUR-DB-USERNAME
password: YOUR-DB-PASSWORD
streamlit:
enabled: True
dialect: postgresql
host: YOUR-DB-HOST
port: 5432
database: YOUR-DB-NAME
username: YOUR-DB-USERNAME
password: YOUR-DB-PASSWORD
sql:
- db1:
dialect: sqlite
database: path/to/local.db
- db2:
dialect: postgresql
host: YOUR-DB-HOST
port: 5432
database: YOUR-DB-NAME
username: YOUR-DB-USERNAME
password: YOUR-DB-PASSWORD
Now you have to load the file into the agent:
agent = Agent('example_agent')
agent.load_properties('config.yaml')
Setting individual properties: You can also set (and get) properties individually from the agent code.
from baf.nlp import NLP_LANGUAGE
...
agent = Agent('example_agent')
agent.set_property(NLP_LANGUAGE, 'es')
...
language = agent.get_property(NLP_LANGUAGE)
Note
When you try to get a property that has not been previously set, it will return its default value.
You can also create your own properties:
from baf.core.property import Property
...
FACEBOOK_PROFILE = Property('facebook.profile', str, 'https://www.facebook.com/foo')
...
agent.set_property(FACEBOOK_PROFILE, 'https://www.facebook.com/john_doe')
Next, let’s see all built-in properties, grouped by domain.
Agent#
Definition of the agent properties within the agent section:
- baf.CHECK_TRANSITIONS_DELAY = <baf.core.property.Property object>#
An agent evaluates periodically all the transitions from the current state to check if someone is satisfied.
This property sets the delay between each transitions evaluation, in seconds.
name:
agent.check_transitions.delaytype:
floatdefault value:
1
NLP#
Definition of the agent properties within the nlp (Natural Language Processing) section
- baf.nlp.HF_TOKEN = <baf.core.property.Property object>#
The HuggingFace (Inference) API key, necessary to use a HuggingFace Inference API LLM.
name:
nlp.huggingface.tokentype:
strdefault value:
None
- baf.nlp.NLP_INTENT_THRESHOLD = <baf.core.property.Property object>#
The threshold for the Intent Classification problem. If none of its predictions have a score greater than the threshold, it will be considered that no intent was detected with enough confidence (and therefore, moving to a fallback scenario).
name:
nlp.intent_thresholdtype:
floatdefault value:
0.4
- baf.nlp.NLP_LANGUAGE = <baf.core.property.Property object>#
The agent language. This is the expected language the users will talk to the agent. Using another language may affect the quality of some NLP processes.
The list of available languages can be found at snowballstemmer. Note that luxembourgish (lb) is also partially supported, as the language can be chosen, yet the stemmer is still a work in progress.
Languages must be written in ISO 639-1 format (e.g., ‘en’ for English)
name:
nlp.languagetype:
strdefault value:
en
- baf.nlp.NLP_PRE_PROCESSING = <baf.core.property.Property object>#
Whether to use text pre-processing or not. Stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form.
Currently, only
SimpleIntentClassifierTorch,SimpleIntentClassifierTFandSimpleNERuse this property. IfLLMIntentClassifieris used, this property is ignored.For example ‘games’ and ‘gaming’ are stemmed to ‘game’.
It can improve the NLP process by generalizing user inputs.
name:
nlp.pre_processingtype:
booldefault value:
True
- baf.nlp.NLP_REGION = <baf.core.property.Property object>#
The language region. If specified, it can improve some NLP process You can find a list of regions here.
name:
nlp.regiontype:
strdefault value:
US
- baf.nlp.NLP_TIMEZONE = <baf.core.property.Property object>#
The timezone. It is used for datetime-related tasks, e.g., to get the current datetime. A list of timezones can be found here.
name:
nlp.timezonetype:
strdefault value:
Europe/Madrid
- baf.nlp.OPENAI_API_KEY = <baf.core.property.Property object>#
The OpenAI API key, necessary to use an OpenAI LLM.
name:
nlp.openai.api_keytype:
strdefault value:
None
- baf.nlp.REPLICATE_API_KEY = <baf.core.property.Property object>#
The Replicate API key, necessary to use a Replicate LLM.
name:
nlp.replicate.api_keytype:
strdefault value:
None
WebSocket Platform#
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_ALIGNMENT = <baf.core.property.Property object>#
Default chat text alignment used by Streamlit chat UI.
name:
platforms.websocket.streamlit.chat.alignmenttype:
strdefault value:
left
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_COLOR = <baf.core.property.Property object>#
Default chat text color used by Streamlit chat UI.
name:
platforms.websocket.streamlit.chat.colortype:
strdefault value:
inherit
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_CONTRAST = <baf.core.property.Property object>#
Default chat contrast level used by Streamlit chat UI.
name:
platforms.websocket.streamlit.chat.contrasttype:
strdefault value:
medium
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_FONT = <baf.core.property.Property object>#
Default chat font family key used by Streamlit chat UI.
name:
platforms.websocket.streamlit.chat.fonttype:
strdefault value:
sans
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_LINE_SPACING = <baf.core.property.Property object>#
Default chat line spacing used by Streamlit chat UI.
name:
platforms.websocket.streamlit.chat.line_spacingtype:
floatdefault value:
1.5
- baf.platforms.websocket.STREAMLIT_CHAT_DEFAULT_SIZE = <baf.core.property.Property object>#
Default chat font size used by Streamlit chat UI when no profile-specific style is applied.
name:
platforms.websocket.streamlit.chat.sizetype:
intdefault value:
16
- baf.platforms.websocket.STREAMLIT_HOST = <baf.core.property.Property object>#
The Streamlit UI host address. If you are using our default UI, you must define its address where you can access and interact with the agent.
name:
platforms.websocket.streamlit.hosttype:
strdefault value:
localhost
- baf.platforms.websocket.STREAMLIT_PORT = <baf.core.property.Property object>#
The Streamlit UI address port. The Streamlit UI address is composed by a host name and a port
name:
platforms.websocket.streamlit.porttype:
intdefault value:
5000
- baf.platforms.websocket.WEBSOCKET_HOST = <baf.core.property.Property object>#
The WebSocket host address. An agent has a WebSocket server that has to establish connection with a WebSocket client.
name:
platforms.websocket.hosttype:
strdefault value:
localhost
- baf.platforms.websocket.WEBSOCKET_MAX_SIZE = <baf.core.property.Property object>#
WebSocket’s maximum size of incoming messages, in bytes.
Nonedisables the limit.name:
platforms.websocket.max_sizetype:
intdefault value:
None
- baf.platforms.websocket.WEBSOCKET_ORIGINS = <baf.core.property.Property object>#
List of allowed origins for WebSocket connections. When set, only connections from these origins will be accepted. When
None(default), connections from any origin are allowed.Example in
config.yaml:platforms: websocket: origins: - "https://editor.besser-pearl.org" - "https://localhost"
name:
platforms.websocket.originstype:
listdefault value:
None
- baf.platforms.websocket.WEBSOCKET_PORT = <baf.core.property.Property object>#
The WebSocket address port. The WebSocket address is composed by a host name and a port
name:
platforms.websocket.porttype:
intdefault value:
8765
Telegram Platform#
Definition of the agent properties within the telegram_platform section:
- baf.platforms.telegram.TELEGRAM_TOKEN = <baf.core.property.Property object>#
The Telegram Bot token. Used to connect to the Telegram Bot
type:
strdefault value:
None
GitHub Platform#
Definition of the agent properties within the github_platform section:
- baf.platforms.github.GITHUB_PERSONAL_TOKEN = <baf.core.property.Property object>#
The Personal Access Token used to connect to the GitHub API
name:
github.personal_tokentype:
strdefault value:
None
- baf.platforms.github.GITHUB_WEBHOOK_PORT = <baf.core.property.Property object>#
The server local port. This port should be exposed of proxied to make it visible by GitHub
name:
github.webhook_porttype:
intdefault value:
8901
- baf.platforms.github.GITHUB_WEBHOOK_TOKEN = <baf.core.property.Property object>#
The secret token defined at the webhook creation
name:
github.webhook_tokentype:
strdefault value:
None
GitLab Platform#
Definition of the agent properties within the gitlab_platform section:
- baf.platforms.gitlab.GITLAB_PERSONAL_TOKEN = <baf.core.property.Property object>#
The Personal Access Token used to connect to the GitLab API
name:
gitlab.personal_tokentype:
strdefault value:
None
- baf.platforms.gitlab.GITLAB_WEBHOOK_PORT = <baf.core.property.Property object>#
The server local port. This port should be exposed of proxied to make it visible by GitLab
name:
gitlab.webhook_porttype:
intdefault value:
8901
- baf.platforms.gitlab.GITLAB_WEBHOOK_TOKEN = <baf.core.property.Property object>#
The secret token defined at the webhook creation
name:
gitlab.webhook_tokentype:
strdefault value:
None
A2A Platform#
Definition of the agent properties within the A2A_platform section:
- baf.platforms.a2a.A2A_WEBSOCKET_PORT = <baf.core.property.Property object>#
The server local port. This port should be exposed or proxied to make it visible by other Agents
name:
a2a.porttype:
intdefault value:
8000
Database#
Definition of the agent properties within the db (Database) section
- baf.db.DB_MONITORING = <baf.core.property.Property object>#
Whether to use the monitoring database or not. If true, all the
DB_MONITORING_*properties must be properly set.name:
db.monitoring.enabledtype:
booldefault value:
False
- baf.db.DB_MONITORING_DATABASE = <baf.core.property.Property object>#
The database name.
name:
db.monitoring.databasetype:
strdefault value:
None
- baf.db.DB_MONITORING_DIALECT = <baf.core.property.Property object>#
The database dialect (e.g.,
postgresql).name:
db.monitoring.dialecttype:
strdefault value:
None
- baf.db.DB_MONITORING_HOST = <baf.core.property.Property object>#
The database host address (e.g.,
localhost).name:
db.monitoring.hosttype:
strdefault value:
None
- baf.db.DB_MONITORING_PASSWORD = <baf.core.property.Property object>#
The database password.
name:
db.monitoring.passwordtype:
strdefault value:
None
- baf.db.DB_MONITORING_PORT = <baf.core.property.Property object>#
The database port (e.g.,
5432).name:
db.monitoring.porttype:
intdefault value:
None
- baf.db.DB_MONITORING_USERNAME = <baf.core.property.Property object>#
The database username.
name:
db.monitoring.usernametype:
strdefault value:
None
Streamlit Database#
Definition of the agent properties within the websocket_platform section:
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT = <baf.core.property.Property object>#
Enable Streamlit user database persistence.
name:
db.streamlit.enabledtype:booldefault value:False
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_DATABASE = <baf.core.property.Property object>#
Database name for Streamlit user database.
name:
db.streamlit.databasetype:strdefault value:None
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_DIALECT = <baf.core.property.Property object>#
Database dialect for Streamlit user database.
name:
db.streamlit.dialecttype:strdefault value:postgresql
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_HOST = <baf.core.property.Property object>#
Database host for Streamlit user database.
name:
db.streamlit.hosttype:strdefault value:None
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_PASSWORD = <baf.core.property.Property object>#
Database password for Streamlit user database.
name:
db.streamlit.passwordtype:strdefault value:None
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_PORT = <baf.core.property.Property object>#
Database port for Streamlit user database.
name:
db.streamlit.porttype:intdefault value:5432
- baf.platforms.websocket.streamlit_ui.DB_STREAMLIT_USERNAME = <baf.core.property.Property object>#
Database username for Streamlit user database.
name:
db.streamlit.usernametype:strdefault value:None
API References#
Agent:
baf.core.agent.AgentAgent.set_property():
baf.core.agent.Agent.set_property()Agent.get_property():
baf.core.agent.Agent.get_property()Property:
baf.core.property.Property