language_detection_processor#

class besser.agent.core.processors.language_detection_processor.LanguageDetectionProcessor(agent, user_messages=False, agent_messages=False)[source]#

Bases: Processor

The LanguageDetectionProcessor returns the spoken language in a given message.

This processor leverages the langdetect library to predict the language.

Parameters:
  • agent (Agent) – The agent the processor belongs to

  • user_messages (bool) – Whether the processor should be applied to user messages

  • agent_messages (bool) – Whether the processor should be applied to agent messages

agent#

The agent the processor belongs to

Type:

Agent

user_messages#

Whether the processor should be applied to user messages

Type:

bool

agent_messages#

Whether the processor should be applied to agent messages

Type:

bool

_abc_impl = <_abc._abc_data object>#
process(session, message)[source]#

Method to process a message and predict the message’s language.

The detected language will be stored as a session parameter. The key is “detected_language”.

Parameters:
  • session (Session) – the current session

  • message (str) – the message to be processed

Returns:

the processed message

Return type:

str