Skip to content

Commit

Permalink
Merge branch 'zAlweNy26-cat_as_singleton' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Oct 23, 2023
2 parents 916f8d2 + 021b4f3 commit 14ecd36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion core/cat/looking_glass/cheshire_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
MSG_TYPES = Literal["notification", "chat", "error", "chat_token"]

# main class
class CheshireCat:
class CheshireCat():
"""The Cheshire Cat.
This is the main class that manages everything.
Expand All @@ -40,6 +40,15 @@ class CheshireCat:
"""

# CheshireCat is a singleton, this is the instance
_instance = None

# get instance or create as the constructor is called
def __new__(cls):
if not cls._instance:
cls._instance = super().__new__(cls)
return cls._instance

def __init__(self):
"""Cat initialization.
Expand Down
2 changes: 1 addition & 1 deletion core/cat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from cat.routes.static import public, admin, static
from cat.api_auth import check_api_key
from cat.routes.openapi import get_openapi_configuration_function
from cat.looking_glass.cheshire_cat import CheshireCat
from cat.looking_glass.cheshire_cat import CheshireCat


@asynccontextmanager
Expand Down
1 change: 0 additions & 1 deletion core/tests/routes/memory/test_memory_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def test_memory_recall_success(client):
episodic_memories = json["vectors"]["collections"]["episodic"]
assert len(episodic_memories) == num_messages # all 3 retrieved


# search with query and k
def test_memory_recall_with_k_success(client):

Expand Down

0 comments on commit 14ecd36

Please sign in to comment.