Multilingual NLU engine for intent classification, escalation detection, and conversation management.
Project description
nlu-core
Multilingual Natural Language Understanding (NLU) engine for customer support chatbots.
Supports English and Bahasa Malaysia (Malay).
Features
- Intent classification — maps customer messages to knowledge-base topics
- Escalation detection — identifies customers who need a human agent
- Conversation summarisation — produces compact conversation summaries for context
- History reply — finds the most relevant previous answer in a conversation
- Product enquiry prompts — builds structured prompts for product recommendation flows
Installation
pip install nlu-core
Quick Start
import pandas as pd
from nlu_core import engine_match, detect_escalation, summarize_conversation
# Load your knowledge base
kb = pd.read_excel("knowledge_base.xlsx", sheet_name="Main DB")
# Classify a customer message
intent, confidence, matched_row = engine_match(
user_question="How do I track my order?",
knowledge_df=kb,
)
# Check for escalation
should_escalate, response = detect_escalation("I want to speak to a manager!")
# Summarise a conversation
summary = summarize_conversation(
history=["Customer: My phone is broken.", "Agent: I can help with that."],
)
API Reference
| Function | Description |
|---|---|
engine_match(user_question, knowledge_df, ...) |
Returns (intent, confidence, matched_row) |
detect_escalation(question) |
Returns (should_escalate: bool, response: str) |
summarize_conversation(history, ...) |
Returns a summary string |
find_relevant_history_reply(history, question, ...) |
Returns the best matching previous reply |
build_product_enquiry_prompt(user_message, stock_json) |
Returns a structured LLM prompt |
Constants
| Name | Description |
|---|---|
DEFAULT_GEMINI_MODEL |
Default primary language model |
DEFAULT_OPENAI_MODEL |
Default translation model |
FALLBACK_GEMINI_MODEL |
Fallback model if primary is unavailable |
LOG_TICKET |
Intent token for support ticket creation |
MATCH_GEMINI_MODEL |
Intent token for product matching |
Requirements
- Python 3.10+
- macOS (Apple Silicon or Intel)
google-genaiopenaipandas
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nlu_core-1.0.0-cp314-cp314-macosx_14_0_arm64.whl.
File metadata
- Download URL: nlu_core-1.0.0-cp314-cp314-macosx_14_0_arm64.whl
- Upload date:
- Size: 64.9 kB
- Tags: CPython 3.14, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf8e8ca0531eabe768b5674b5bbad58ac14024a62fca6279f8ac6d94b51695bd
|
|
| MD5 |
e91b560d7a679e0a399d919dea2cd97b
|
|
| BLAKE2b-256 |
86111f7173d48bc904913bcd408496b5bc1ad20e89fa05fca60fc14b4a3df4e8
|