Zum Inhalt springen

Rasa - Conversational AI Framework Cheatsheet

Rasa - Conversational AI Framework Cheatsheet

Rasa ist ein Open-Source-Framework zum Bauen von kontextuellen Conversational Assistants. Anders als Prompt-only Chatbots gibt dir Rasa explizite Kontrolle über Dialogue: du definierst Intents, Entities und Flows, und der Assistant folgt Business Logic, die du spezifizierst, anstatt was auch immer das Modell improvisiert. Alles läuft auf deiner eigenen Infrastruktur, was in regulierten Domains wichtig ist. Modernes Rasa (CALM) mischt LLM-gesteuertes Verstehen mit deterministischer Flow-Ausführung — das Modell interpretiert, deine Flows entscheiden.

Installation

MethodeBefehl
pippip install rasa
New Projectrasa init
AnforderungenPython 3.9–3.11 (prüfe aktuelle Unterstützung)
Verifikationrasa --version

Projekt-Struktur

PathEnthält
domain.ymlIntents, Entities, Slots, Responses, Actions
data/nlu.ymlTraining Examples pro Intent
data/stories.ymlBeispiel Conversation Paths
data/rules.ymlDeterministische Rules
data/flows.ymlCALM Business-Logic Flows
config.ymlNLU/Policy Pipeline
actions/actions.pyCustom Python Actions

Core CLI

BefehlBeschreibung
rasa initScaffold ein neues Assistants
rasa trainTrain das Modell
rasa shellChat damit im Terminal
rasa runStarte den Server
rasa run actionsStarte den Custom Action Server
rasa testFühre Tests gegen Test Stories aus
rasa interactiveInteractive Training/Correction
rasa data validatePrüfe Data Consistency

Intents & Responses definieren

# domain.yml
intents:
  - greet
  - check_balance

responses:
  utter_greet:
    - text: "Hi! How can I help?"

slots:
  account_id:
    type: text
    mappings:
      - type: from_entity
        entity: account_id

actions:
  - action_fetch_balance
# data/nlu.yml
nlu:
  - intent: check_balance
    examples: |
      - what's my balance
      - how much money do I have
      - show account [12345](account_id)

Flows (CALM)

# data/flows.yml
flows:
  check_balance:
    description: Look up the user's account balance
    steps:
      - collect: account_id
      - action: action_fetch_balance
      - action: utter_balance
Step-TypTut
collectFrag nach und fülle einen Slot
actionFühre eine Custom oder Utter Action aus
linkJump zu einem anderen Flow
set_slotsAssigned Slot-Werte
next mit ifConditional Branching

Flows sind deterministisch: das LLM entscheidet, welcher Flow der User will, aber der Flow selbst führt genau wie geschrieben aus.

Custom Actions

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionFetchBalance(Action):
    def name(self) -> str:
        return "action_fetch_balance"

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain):
        account = tracker.get_slot("account_id")
        balance = lookup_balance(account)
        dispatcher.utter_message(text=f"Your balance is ${balance}")
        return []

Führe mit rasa run actions aus (Standard-Port 5055).

Testing

rasa test                 # end-to-end tests
rasa test nlu --cross-validation
rasa data validate        # catch domain/data mismatches
Test-TypPrüft
NLU TestsIntent/Entity Accuracy
Story TestsVolle Conversation Paths
Cross-validationGeneralization der NLU

Channels & Deployment

ChannelNotiz
RESTStandard HTTP Endpunkt
Web WidgetEmbeddable Chat
Slack / Teams / TelegramBuilt-in Connectors
VoiceVia Telephony Integrations
DeploymentDocker, Kubernetes/Helm, Self-hosted

Rasa vs LLM-Only Chatbots

AspektRasaPrompt-only LLM Bot
ControlExplizite Flows/Business LogicEmergent, schwer zu constrainen
PredictabilityHochVariabel
ComplianceAuditable PathsSchwierig
HostingVollständig Self-hostedUsually API-abhängig
Am besten fürRegulierte, Task-orientierte AssistantsOpen-ended Conversation

Für Open-Ended Agents siehe LangGraph oder Mastra; Rasas Stärke ist deterministische, auditable Task Flows.

Ressourcen