Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions parrot/serve/variable_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,13 @@ def create_var(self, session_id: int, var_name: str) -> SemanticVariable:
)

def get_var(self, session_id: int, var_id: str) -> SemanticVariable:
"""Get a Semantic Variable by ID.
"""Get a session-local Semantic Variable by ID.

Args:
session_id: int. The session ID.
var_id: str. The Semantic Variable ID.
"""

cp_var = self.constant_prefix_namespace.get_var_by_id(var_id)
if cp_var is not None:
return cp_var

parrot_assert(
session_id in self.session_namespaces,
f"Local namespace of {session_id} does not exist.",
Expand Down
18 changes: 18 additions & 0 deletions tests/serve/test_sv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pytest

from parrot.exceptions import ParrotCoreUserError
from parrot.serve.graph import (
RequestChain,
ConstantFill,
Expand All @@ -22,6 +25,21 @@ def test_content_hash():
assert var1 == var2


def test_constant_prefix_is_not_exposed_through_session_lookup():
var_mgr = SemanticVariableManager(constant_prefix_var_timeout=10)
owner_session_id = 0
other_session_id = 1
var_mgr.register_local_var_space(owner_session_id)
var_mgr.register_local_var_space(other_session_id)

prefix_var = var_mgr._get_constant_prefix_var("private system prompt")

with pytest.raises(ParrotCoreUserError):
var_mgr.get_var(owner_session_id, prefix_var.id)
with pytest.raises(ParrotCoreUserError):
var_mgr.get_var(other_session_id, prefix_var.id)


def test_request_chain_hash():
var_mgr = SemanticVariableManager(constant_prefix_var_timeout=10)

Expand Down
Loading