Skip to main content

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-genai
  • openai
  • pandas

Project details


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

If you're not sure about the file name format, learn more about wheel file names.

nlu_core-1.0.0-cp314-cp314-macosx_14_0_arm64.whl (64.9 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

File details

Details for the file nlu_core-1.0.0-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for nlu_core-1.0.0-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bf8e8ca0531eabe768b5674b5bbad58ac14024a62fca6279f8ac6d94b51695bd
MD5 e91b560d7a679e0a399d919dea2cd97b
BLAKE2b-256 86111f7173d48bc904913bcd408496b5bc1ad20e89fa05fca60fc14b4a3df4e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page