Skip to content

Commit

Permalink
backwards compat
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Oct 3, 2023
1 parent c93a583 commit 896d84b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions ovos_bus_client/session.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import enum
import json
import time
from threading import Lock
from typing import Optional, List, Tuple, Union, Iterable
from uuid import uuid4

from ovos_bus_client.message import dig_for_message, Message
from ovos_config.config import Configuration
from ovos_config.locale import get_default_lang
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.log import LOG

from ovos_bus_client.message import dig_for_message, Message


class UtteranceState(str, enum.Enum):
Expand Down Expand Up @@ -268,6 +268,7 @@ def get_context(self, max_frames: int = None,
class Session:
def __init__(self, session_id: str = None, expiration_seconds: int = None,
active_skills: List[List[Union[str, float]]] = None,
history=None, max_time=None, max_messages=None,
utterance_states: dict = None, lang: str = None,
context: IntentContextManager = None,
valid_langs: List[str] = None,
Expand All @@ -278,6 +279,9 @@ def __init__(self, session_id: str = None, expiration_seconds: int = None,
@param session_id: string UUID for the session
@param expiration_seconds: TTL for session (-1 for no expiration)
@param active_skills: List of list skill_id, last reference
@param history: DEPRECATED
@param max_time: DEPRECATED
@param max_messages: DEPRECATED
@param utterance_states: dict of skill_id to UtteranceState
@param lang: language associated with this Session
@param context: IntentContextManager for this Session
Expand Down Expand Up @@ -307,6 +311,13 @@ def __init__(self, session_id: str = None, expiration_seconds: int = None,
]
self.context = context or IntentContextManager(timeout=self.touch_time + self.expiration_seconds)

# deprecated - TODO remove 0.0.8
if history is not None or max_time is not None or max_messages is not None:
LOG.warning("history, max_time and max_messages have been deprecated")
self.history = [] # (Message , timestamp)
self.max_time = 5 # minutes
self.max_messages = 5

@property
def active(self) -> bool:
"""
Expand Down Expand Up @@ -404,6 +415,14 @@ def serialize(self) -> dict:
"pipeline": self.pipeline
}

def update_history(self, message: Message = None):
"""
Add a message to history and then prune history
@param message: Message to append to history
"""
LOG.warning("update_history has been deprecated, "
"session no longer has a message history")

@staticmethod
def deserialize(data: dict):
"""
Expand Down

0 comments on commit 896d84b

Please sign in to comment.