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 section, a name, a type and a default value (for when the property is not defined by the agent developer).

Loading properties#

You can define your agent properties in 2 different ways:

  • Using a configuration `.ini` file: It is a file containing all the agent properties. Let’s see an example config.ini file:

[agent]
agent.check_transitions.delay = 2

[websocket_platform]
websocket.host = localhost
websocket.port = 8765
streamlit.host = localhost
streamlit.port = 5000

[telegram_platform]
telegram.token = YOUR-BOT-TOKEN

[github_platform]
github.personal_token = GITHUB-PERSONAL-TOKEN
github.webhook_token = WEBHOOK-TOKEN
github.webhook_port = 8901

[gitlab_platform]
gitlab.personal_token = GITLAB-PERSONAL-TOKEN
gitlab.webhook_token = WEBHOOK-TOKEN
gitlab.webhook_port = 8901

[nlp]
nlp.language = en
nlp.region = US
nlp.timezone = Europe/Madrid
nlp.pre_processing = True
nlp.intent_threshold = 0.4
nlp.openai.api_key = YOUR-API-KEY
nlp.hf.api_key = YOUR-API-KEY
nlp.replicate.api_key = YOUR-API-KEY

[db]
db.monitoring = False
db.monitoring.dialect = postgresql
db.monitoring.host = localhost
db.monitoring.port = 5432
db.monitoring.database = DB-NAME
db.monitoring.username = DB-USERNAME
db.monitoring.password = DB-PASSWORD

Now you have to load the file into the agent:

agent = Agent('example_agent')
agent.load_properties('config.ini')
  • Setting individual properties: You can also set (and get) properties individually from the agent code.

from besser.agent.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 besser.agent.core.property import Property
...
FACEBOOK_PROFILE = Property('facebook', 'facebook.profile', str, 'https://www.facebook.com/foo')
...
agent.set_property(FACEBOOK_PROFILE, 'https://www.facebook.com/john_doe')

Next, let’s see all the built in properties, divided by sections.

Agent#

Definition of the agent properties within the agent section:

besser.agent.CHECK_TRANSITIONS_DELAY = <besser.agent.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.delay

type: float

default value: 1

NLP#

Definition of the agent properties within the nlp (Natural Language Processing) section

besser.agent.nlp.HF_API_KEY = <besser.agent.core.property.Property object>#

The HuggingFace (Inference) API key, necessary to use a HuggingFace Inference API LLM.

name: nlp.hf.api_key

type: str

default value: None

besser.agent.nlp.NLP_INTENT_THRESHOLD = <besser.agent.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_threshold

type: float

default value: 0.4

besser.agent.nlp.NLP_LANGUAGE = <besser.agent.core.property.Property object>#

The agenr 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.language

type: str

default value: en

besser.agent.nlp.NLP_PRE_PROCESSING = <besser.agent.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, SimpleIntentClassifierTF and SimpleNER use this property. If LLMIntentClassifier is 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_processing

type: bool

default value: True

besser.agent.nlp.NLP_REGION = <besser.agent.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.region

type: str

default value: US

besser.agent.nlp.NLP_STT_HF_MODEL = <besser.agent.core.property.Property object>#

The name of the Hugging Face model for the HFSpeech2Text agent component. If none is provided, the component will not be activated.

name: nlp.speech2text.hf.model

type: str

default value: None

besser.agent.nlp.NLP_STT_SR_ENGINE = <besser.agent.core.property.Property object>#

The name of the transcription engine for the Speech Recognition agent component. If none is provided, the component will not be activated.

name: nlp.speech2text.sr.engine

type: str

default value: None

besser.agent.nlp.NLP_TIMEZONE = <besser.agent.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.timezone

type: str

default value: Europe/Madrid

besser.agent.nlp.OPENAI_API_KEY = <besser.agent.core.property.Property object>#

The OpenAI API key, necessary to use an OpenAI LLM.

name: nlp.openai.api_key

type: str

default value: None

besser.agent.nlp.REPLICATE_API_KEY = <besser.agent.core.property.Property object>#

The Replicate API key, necessary to use a Replicate LLM.

name: nlp.replicate.api_key

type: str

default value: None

WebSocket Platform#

Definition of the agent properties within the websocket_platform section:

besser.agent.platforms.websocket.STREAMLIT_HOST = <besser.agent.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: streamlit.host

type: str

default value: localhost

besser.agent.platforms.websocket.STREAMLIT_PORT = <besser.agent.core.property.Property object>#

The Streamlit UI address port. The Streamlit UI address is composed by a host name and a port

name: streamlit.port

type: int

default value: 5000

besser.agent.platforms.websocket.WEBSOCKET_HOST = <besser.agent.core.property.Property object>#

The WebSocket host address. An agent has a WebSocket server that has to establish connection with a WebSocket client.

name: websocket.host

type: str

default value: localhost

besser.agent.platforms.websocket.WEBSOCKET_MAX_SIZE = <besser.agent.core.property.Property object>#

WebSocket’s maximum size of incoming messages, in bytes. None disables the limit.

name: websocket.max_size

type: int

default value: None

besser.agent.platforms.websocket.WEBSOCKET_PORT = <besser.agent.core.property.Property object>#

The WebSocket address port. The WebSocket address is composed by a host name and a port

name: websocket.port

type: int

default value: 8765

Telegram Platform#

Definition of the agent properties within the telegram_platform section:

besser.agent.platforms.telegram.TELEGRAM_TOKEN = <besser.agent.core.property.Property object>#

The Telegram Bot token. Used to connect to the Telegram Bot

type: str

default value: None

GitHub Platform#

Definition of the agent properties within the github_platform section:

besser.agent.platforms.github.GITHUB_PERSONAL_TOKEN = <besser.agent.core.property.Property object>#

The Personal Access Token used to connect to the GitHub API

name: github.personal_token

type: str

default value: None

besser.agent.platforms.github.GITHUB_WEBHOOK_PORT = <besser.agent.core.property.Property object>#

The server local port. This port should be exposed of proxied to make it visible by GitHub

name: github.webhook_port

type: int

default value: 8901

besser.agent.platforms.github.GITHUB_WEBHOOK_TOKEN = <besser.agent.core.property.Property object>#

The secret token defined at the webhook creation

name: github.webhook_token

type: str

default value: None

GitLab Platform#

Definition of the agent properties within the gitlab_platform section:

besser.agent.platforms.gitlab.GITLAB_PERSONAL_TOKEN = <besser.agent.core.property.Property object>#

The Personal Access Token used to connect to the GitLab API

name: gitlab.personal_token

type: str

default value: None

besser.agent.platforms.gitlab.GITLAB_WEBHOOK_PORT = <besser.agent.core.property.Property object>#

The server local port. This port should be exposed of proxied to make it visible by GitLab

name: gitlab.webhook_port

type: int

default value: 8901

besser.agent.platforms.gitlab.GITLAB_WEBHOOK_TOKEN = <besser.agent.core.property.Property object>#

The secret token defined at the webhook creation

name: gitlab.webhook_token

type: str

default value: None

Database#

Definition of the agent properties within the db (Database) section

besser.agent.db.DB_MONITORING = <besser.agent.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

type: bool

default value: False

besser.agent.db.DB_MONITORING_DATABASE = <besser.agent.core.property.Property object>#

The database name.

name: db.monitoring.database

type: str

default value: None

besser.agent.db.DB_MONITORING_DIALECT = <besser.agent.core.property.Property object>#

The database dialect (e.g., postgresql).

name: db.monitoring.dialect

type: str

default value: None

besser.agent.db.DB_MONITORING_HOST = <besser.agent.core.property.Property object>#

The database host address (e.g., localhost).

name: db.monitoring.host

type: str

default value: None

besser.agent.db.DB_MONITORING_PASSWORD = <besser.agent.core.property.Property object>#

The database password.

name: db.monitoring.password

type: str

default value: None

besser.agent.db.DB_MONITORING_PORT = <besser.agent.core.property.Property object>#

The database port (e.g., 5432).

name: db.monitoring.port

type: int

default value: None

besser.agent.db.DB_MONITORING_USERNAME = <besser.agent.core.property.Property object>#

The database username.

name: db.monitoring.username

type: str

default value: None

API References#