Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
27 changes: 27 additions & 0 deletions actions/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This files contains your custom actions which can be used to run
# custom Python code.
#
# See this guide on how to implement these action:
# https://rasa.com/docs/rasa/custom-actions


# This is a simple example for a custom action which utters "Hello World!"

# from typing import Any, Text, Dict, List
#
# from rasa_sdk import Action, Tracker
# from rasa_sdk.executor import CollectingDispatcher
#
#
# class ActionHelloWorld(Action):
#
# def name(self) -> Text:
# return "action_hello_world"
#
# def run(self, dispatcher: CollectingDispatcher,
# tracker: Tracker,
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
#
# dispatcher.utter_message(text="Hello World!")
#
# return []
50 changes: 50 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# The config recipe.
# https://rasa.com/docs/rasa/model-configuration/
recipe: default.v1

# The assistant project unique identifier
# This default value must be replaced with a unique assistant name within your deployment
assistant_id: 20260414-120228-frosty-HUD

# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en

pipeline: null
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
# - name: WhitespaceTokenizer
# - name: RegexFeaturizer
# - name: LexicalSyntacticFeaturizer
# - name: CountVectorsFeaturizer
# - name: CountVectorsFeaturizer
# analyzer: char_wb
# min_ngram: 1
# max_ngram: 4
# - name: DIETClassifier
# epochs: 100
# constrain_similarities: true
# - name: EntitySynonymMapper
# - name: ResponseSelector
# epochs: 100
# constrain_similarities: true
# - name: FallbackClassifier
# threshold: 0.3
# ambiguity_threshold: 0.1

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies: null
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
# - name: MemoizationPolicy
# - name: RulePolicy
# - name: UnexpecTEDIntentPolicy
# max_history: 5
# epochs: 100
# - name: TEDPolicy
# max_history: 5
# epochs: 100
# constrain_similarities: true
33 changes: 33 additions & 0 deletions credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/messaging-and-voice-channels

rest:
# # you don't need to provide anything here - this channel doesn't
# # require any credentials


#facebook:
# verify: "<verify>"
# secret: "<your secret>"
# page-access-token: "<your page access token>"

#slack:
# slack_token: "<your slack token>"
# slack_channel: "<the slack channel>"
# slack_signing_secret: "<your slack signing secret>"

#socketio:
# user_message_evt: <event name for user message>
# bot_message_evt: <event name for bot messages>
# session_persistence: <true/false>

#mattermost:
# url: "https://<mattermost instance>/api/v4"
# token: "<bot token>"
# webhook_url: "<callback URL>"

# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
url: "http://localhost:5002/api"
33 changes: 33 additions & 0 deletions cxx_tracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json
from rasa.core.tracker_store import TrackerStore
from rasa.shared.core.trackers import DialogueStateTracker
import fast_tracker

class CppTrackerStore(TrackerStore):
def __init__(self, domain, event_broker=None, **kwargs):
super().__init__(domain, event_broker, **kwargs)
self.engine = fast_tracker.CppTrackerEngine()
print("🤖 [SYSTEM INFO] Core Engine initialized using C++ Hijack.")

async def save(self, tracker, timeout=None):
# Extract the serializable list of dictionaries representing tracker events
events_list = [e.as_dict() for e in tracker.events]
state_json = json.dumps(events_list)

print(f"⚡ [C++ WRITE] Routing dialogue state for '{tracker.sender_id}' to C++ layer.")
self.engine.save(tracker.sender_id, state_json)

async def retrieve(self, sender_id):
state_json = self.engine.retrieve(sender_id)
if not state_json:
return None

print(f"🔍 [C++ READ] Retrieving session state for '{sender_id}' from C++.")
events_as_dict = json.loads(state_json)

# Reconstruct the DialogueStateTracker by replaying the stored events
return DialogueStateTracker.from_dict(
sender_id,
events_as_dict,
self.domain.slots
)
19 changes: 12 additions & 7 deletions data/rasa_yaml_examples/nlu.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
version: "3.1"

nlu:
- intent: estimate_emissions
# Arbitrary metadata
metadata:
author: Some example metadata!
key: value
# Multiline examples, each line is a separate training example.
examples: |
how much CO2 will that use?
how much carbon will a one way flight from [new york]{"entity": "city", "role": "from"} to california produce?
- how much CO2 will that use?
- how much carbon will a one way flight from [new york]{"entity": "city", "role": "from"} to [california]{"entity": "city", "role": "to"} produce?

- intent: give_name
examples: |
- my name is lors
- I am Francelle
- call me Lorraine
- I'm Sam
- my name is [lors](name)
6 changes: 6 additions & 0 deletions data/rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3.1"
rules:
- rule: Say goodbye anytime the user leaves
steps:
- intent: goodbye
- action: utter_goodbye
8 changes: 8 additions & 0 deletions data/stories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.1"
stories:
- story: capture session state path
steps:
- intent: greet
- action: utter_greet
- intent: give_name
- action: utter_greet_with_name
46 changes: 46 additions & 0 deletions domain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "3.1"

intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- give_name
slots:
user_name: # This is the "bucket" in the bot's memory
type: text
influence_conversation: true
mappings:
- type: from_text # AUTOMATION: This captures everything you type
intent: give_name # ...but only when you are introducing yourself

responses:
utter_greet:
- text: "System online. Streaming conversation tracking inputs directly."

# Add this so the bot can actually use the name it stored
utter_greet_with_name:
- text: "Nice to meet you, {user_name}!"

utter_cheer_up:
- text: "Here is something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"

utter_did_that_help:
- text: "Did that help you?"

utter_happy:
- text: "Great, carry on!"

utter_goodbye:
- text: "Session terminated. Clearing cache."

utter_iamabot:
- text: "I am a bot, powered by Rasa."

session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
5 changes: 5 additions & 0 deletions endpoints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
action_endpoint:
url: "http://localhost:5055/webhook"

tracker_store:
type: cxx_tracker.CppTrackerStore
Binary file added fast_tracker.cp310-win_amd64.pyd
Binary file not shown.
43 changes: 43 additions & 0 deletions load_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import asyncio
import aiohttp
import time

URL = "http://localhost:5005/webhooks/rest/webhook"
TOTAL_REQUESTS = 1000

async def send_message(session, user_id):
payload = {
"sender": f"test_user_{user_id}",
"message": "hello"
}

start_time = time.time()
try:
async with session.post(URL, json=payload) as response:
await response.json()
latency = time.time() - start_time
return latency
except Exception as e:
return None

async def main():
print(f" Launching {TOTAL_REQUESTS} simultaneous requests straight to the C++ Tracker Store...")

async with aiohttp.ClientSession() as session:
start_time = time.time()
tasks = [send_message(session, i) for i in range(TOTAL_REQUESTS)]
latencies = await asyncio.gather(*tasks)
total_time = time.time() - start_time

successful_latencies = [l for l in latencies if l is not None]

print("\n--- PERFORMANCE BENCHMARK RESULTS ---")
print(f"Total Time for {TOTAL_REQUESTS} requests: {total_time:.2f} seconds")
print(f"Successful Responses: {len(successful_latencies)}/{TOTAL_REQUESTS}")
if successful_latencies:
print(f"Average Latency per request: {sum(successful_latencies)/len(successful_latencies):.4f} seconds")
print(f"Max Latency: {max(successful_latencies):.4f} seconds")

if __name__ == "__main__":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
File renamed without changes.
13 changes: 13 additions & 0 deletions research_data/rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.1"

rules:

- rule: Say goodbye anytime the user says goodbye
steps:
- intent: goodbye
- action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
steps:
- intent: bot_challenge
- action: utter_iamabot
File renamed without changes.
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext

ext_modules = [
Pybind11Extension("fast_tracker", ["tracker.cpp"]),
]

setup(
name="fast_tracker",
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext},
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ responses:
- text: goodbye :(
utter_default:
- text: default message
utter_greet:
- text: hey there!

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ entities:
- name

responses:
utter_greet:

utter_goodbye:
- text: goodbye :(
utter_default:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading