llm_intent_classifier#
- class besser.agent.nlp.intent_classifier.llm_intent_classifier.LLMIntentClassifier(nlp_engine, state)[source]#
Bases:
IntentClassifier
An LLM-based Intent Classifier.
It sends a prompt to an LLM, indicating how to perform the Intent Classification task and providing the State’s intents and its parameters
- Parameters:
Attributes:
See also
- _abc_impl = <_abc._abc_data object>#
- _generate_prompt(message)[source]#
Generates the prompt for the LLM giving instructions for the intent classification task.
- default_json_to_intent_classifier_predictions(message, response_json)[source]#
Parse the JSON generated by an LLM to the list of intent classifier prediction objects.
The expected JSON structure is the following:
{ 'intent1': { 'score': 0.7, 'parameters': { 'param1': 'value1', 'param2': 'value2' } }, 'intent2': {...} }
- Parameters:
- Returns:
the list of intent classifier predictions
- Return type:
- predict(message)[source]#
Predict the intent of a given message.
Instead of returning only the intent with the highest likelihood, return all predictions. Predictions include not only the intent scores but other information extracted from the message.
- Parameters:
message (str) – the message to predict the intent
- Returns:
the list of predictions made by the intent classifier.
- Return type: