Skip to main content

LLM-powered working memory for Vietnamese bus booking bots

Project description

BusBotMemory SDK

LLM-powered working memory for Vietnamese bus booking bots.

Installation

pip install busbot-memory

Or install from source:

cd busbot-memory
pip install -e .

Quick Start

import asyncio
from busbot_memory import BusBotMemory, BusBotConfig

async def main():
    # Configure (set GROQ_API_KEY env var or pass directly)
    config = BusBotConfig(groq_api_key="gsk_xxx")
    
    # Initialize memory for a session
    memory = BusBotMemory(
        session_id="call_001",
        customer_id="0987654321",
        config=config
    )
    
    # Process messages
    result = await memory.process("đặt 2 vé đi đà nẵng ngày mai 8h sáng")
    
    print(result.state.slots)
    # {"destination": "Đà Nẵng", "date": "ngày mai", "time": "08:00", "quantity": 2}

asyncio.run(main())

Features

  • LLM-powered extraction: Uses Groq (llama-3.3-70b) for accurate entity extraction
  • Change-of-mind detection: Automatically detects when user changes their booking
  • State tracking: Maintains structured booking state with missing slot tracking
  • Low latency: Optimized for < 250ms processing time
  • Fallback support: Falls back to regex when LLM is unavailable

Configuration

config = BusBotConfig(
    # LLM Provider (at least one required)
    groq_api_key="gsk_xxx",           # Primary - fast & free
    openai_api_key="sk-xxx",          # Optional fallback
    
    # Performance
    latency_target_ms=250,
    enable_fallback=True,             # Use regex if LLM fails
    
    # Memory settings
    max_working_items=20,
    max_context_window=5,
)

ProcessResult

result = await memory.process(message)

result.entities       # Extracted entities
result.state          # BookingState object
result.is_noise       # Is filler message ("ừ", "ok")
result.is_change      # Did user change their mind
result.changes        # List of changes made
result.intent         # Detected intent
result.latency_ms     # Processing time

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

busbot_memory-0.1.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

busbot_memory-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file busbot_memory-0.1.0.tar.gz.

File metadata

  • Download URL: busbot_memory-0.1.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for busbot_memory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 36bf77ebab3298bacf34a45d2f7246a7673c66f6cf0a92bd1a3416d1404bb1d0
MD5 35a2ec3d6987da61dd3bd0690deb1199
BLAKE2b-256 64927dac8e2ffeb2e55833e299a70105f0529c00dee2f105da3e7738c42f6977

See more details on using hashes here.

File details

Details for the file busbot_memory-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: busbot_memory-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for busbot_memory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 464a62ba3a0825385d5660072429c33746a02690365cdaa26f995c702570d5ac
MD5 55aa6c04db6feeb738ea74dee8e311c1
BLAKE2b-256 f1cdf1684696632c8cf42b2d9d7e5cbe58d71bbb50caaf4b41341756196859e1

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