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
2 changes: 1 addition & 1 deletion src/sequrity/control/resources/langgraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, transport: ControlSyncTransport) -> None:

def run(
self,
graph: "StateGraph",
graph: StateGraph,
initial_state: dict,
model: str,
*,
Expand Down
8 changes: 5 additions & 3 deletions src/sequrity/control/resources/langgraph/_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Python code and maps nodes to tool definitions.
"""

from __future__ import annotations

import json
from typing import Callable

Expand All @@ -29,7 +31,7 @@ class LangGraphExecutor:

def __init__(
self,
graph: "StateGraph",
graph: StateGraph,
node_functions: dict[str, Callable] | None = None,
internal_node_mapping: dict[str, str] | None = None,
):
Expand Down Expand Up @@ -65,7 +67,7 @@ def __init__(
# Generate code once at initialization
self.generated_code = self._graph_to_code(graph, self.node_functions)

def _extract_function_map(self, graph: "StateGraph") -> dict[str, Callable]:
def _extract_function_map(self, graph: StateGraph) -> dict[str, Callable]:
"""Extract node functions from LangGraph StateGraph."""
function_map = {}

Expand Down Expand Up @@ -160,7 +162,7 @@ def execute_tool_call(self, tool_call: dict, rest_api_type: RestApiType = RestAp

return result

def _graph_to_code(self, graph: "StateGraph", function_map: dict[str, Callable]) -> str:
def _graph_to_code(self, graph: StateGraph, function_map: dict[str, Callable]) -> str:
"""Convert a LangGraph StateGraph into executable Python code."""
nodes = graph.nodes
edges = list(graph.edges)
Expand Down
2 changes: 1 addition & 1 deletion src/sequrity/control/resources/langgraph/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _run_messages_loop(
def run_graph_sync(
transport: ControlSyncTransport,
model: str,
graph: "StateGraph",
graph: StateGraph,
initial_state: dict,
*,
initial_state_meta: MetaData | None = None,
Expand Down
16 changes: 9 additions & 7 deletions src/sequrity/control/types/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
HTTP headers: ``X-Features``, ``X-Policy``, and ``X-Config``.
"""

from __future__ import annotations

from typing import Literal, TypeAlias, overload

from pydantic import BaseModel, ConfigDict, Field
Expand Down Expand Up @@ -99,7 +101,7 @@ def _build(
finance_guardrail: bool,
url_blocker: bool,
file_blocker: bool,
) -> "FeaturesHeader":
) -> FeaturesHeader:
classifiers: list[TaggerConfig] = []
if toxicity_filter:
classifiers.append(TaggerConfig(name="toxicity_filter"))
Expand Down Expand Up @@ -131,7 +133,7 @@ def single_llm(
finance_guardrail: bool = False,
url_blocker: bool = False,
file_blocker: bool = False,
) -> "FeaturesHeader":
) -> FeaturesHeader:
"""Create a Single LLM features configuration."""
return cls._build(
"single-llm",
Expand All @@ -152,7 +154,7 @@ def dual_llm(
finance_guardrail: bool = False,
url_blocker: bool = False,
file_blocker: bool = False,
) -> "FeaturesHeader":
) -> FeaturesHeader:
"""Create a Dual LLM features configuration."""
return cls._build(
"dual-llm",
Expand Down Expand Up @@ -283,7 +285,7 @@ def dual_llm(
branching_meta_policy_producers: set[str] | None = None,
branching_meta_policy_tags: set[str] | None = None,
branching_meta_policy_consumers: set[str] | None = None,
) -> "SecurityPolicyHeader":
) -> SecurityPolicyHeader:
"""Create a Dual LLM security policy configuration."""
return cls.model_validate(
{
Expand Down Expand Up @@ -317,7 +319,7 @@ def single_llm(
default_allow: bool = True,
enable_llm_blocked_tag: bool = True,
llm_blocked_tag_enforcement_level: Literal["hard", "soft"] = "hard",
) -> "SecurityPolicyHeader":
) -> SecurityPolicyHeader:
"""Create a Single LLM security policy configuration."""
return cls.model_validate(
{
Expand Down Expand Up @@ -607,7 +609,7 @@ def single_llm(
min_num_tools_for_filtering: int | None = 10,
clear_session_meta: Literal["never", "every_attempt", "every_turn"] = "never",
max_n_turns: int | None = 50,
) -> "FineGrainedConfigHeader":
) -> FineGrainedConfigHeader:
"""Create a Single LLM fine-grained configuration."""
return cls(
fsm=FsmOverrides(
Expand Down Expand Up @@ -643,7 +645,7 @@ def dual_llm(
include_program: bool | None = None,
include_policy_check_history: bool | None = None,
include_namespace_snapshot: bool | None = None,
) -> "FineGrainedConfigHeader":
) -> FineGrainedConfigHeader:
"""Create a Dual LLM fine-grained configuration."""
fsm = FsmOverrides(
min_num_tools_for_filtering=min_num_tools_for_filtering,
Expand Down