nemo-relay-plugin 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """Author out-of-process NeMo Relay worker plugins in Python.
5
+
6
+ Use :class:`WorkerPlugin` and :class:`PluginContext` to define plugin behavior,
7
+ then pass the implementation to :func:`serve_plugin`. The SDK owns the
8
+ ``grpc-v1`` transport, host authentication, JSON envelopes, continuation calls,
9
+ and task-local scope-stack propagation.
10
+
11
+ The worker can keep multiple RPCs in flight, but callback execution is
12
+ cooperative. Asynchronous callbacks overlap only when they yield control at an
13
+ ``await``. Synchronous callbacks run on the worker event-loop thread and must
14
+ not perform blocking I/O or long-running CPU work. Wrap blocking work in an
15
+ asynchronous callback and offload it with :func:`asyncio.to_thread` or another
16
+ appropriate executor.
17
+
18
+ Public data types:
19
+ Json: Any JSON-serializable Python value.
20
+ Event: A Relay event represented as a JSON object.
21
+ LlmRequest: A Relay LLM request represented as a JSON object.
22
+ AnnotatedLlmRequest: An annotated Relay LLM request represented as a JSON
23
+ object.
24
+ PendingMarkSpec: A mark Relay emits under its managed lifecycle scope.
25
+ LlmRequestInterceptOutcome: Canonical LLM request-intercept result.
26
+ ToolExecutionInterceptOutcome: Canonical tool execution-intercept result.
27
+ DiagnosticLevel: Severity of a configuration diagnostic.
28
+ ConfigDiagnostic: Structured configuration warning or error.
29
+ ScopeType: Semantic category for a Relay execution scope.
30
+ WorkerSdkError: SDK, host-call, or worker protocol error.
31
+
32
+ Public callback aliases:
33
+ SubscriberCallback: Event subscriber callback.
34
+ ToolSanitizeCallback: Tool request or response sanitizer callback.
35
+ ToolConditionalCallback: Tool execution guardrail callback.
36
+ ToolRequestCallback: Tool request intercept callback.
37
+ ToolExecutionCallback: Tool execution intercept callback.
38
+ LlmSanitizeRequestCallback: LLM request sanitizer callback.
39
+ LlmSanitizeResponseCallback: LLM response sanitizer callback.
40
+ LlmConditionalCallback: LLM execution guardrail callback.
41
+ LlmRequestCallback: LLM request intercept callback.
42
+ LlmExecutionCallback: Unary LLM execution intercept callback.
43
+ LlmStreamExecutionCallback: Streaming LLM execution intercept callback.
44
+
45
+ Public authoring types:
46
+ WorkerPlugin: Base validation and registration contract for a plugin.
47
+ PluginContext: Component-scoped callback registration context.
48
+ PluginRuntime: Host runtime handle for event and scope operations.
49
+ ToolNext: Continuation for a tool execution intercept.
50
+ LlmNext: Continuation for a unary LLM execution intercept.
51
+ LlmStreamNext: Continuation for a streaming LLM execution intercept.
52
+
53
+ Public functions:
54
+ serve_plugin: Run a local ``grpc-v1`` worker until host shutdown.
55
+ """
56
+
57
+ from ._api import (
58
+ AnnotatedLlmRequest,
59
+ ConfigDiagnostic,
60
+ DiagnosticLevel,
61
+ Event,
62
+ Json,
63
+ LlmConditionalCallback,
64
+ LlmExecutionCallback,
65
+ LlmNext,
66
+ LlmRequest,
67
+ LlmRequestCallback,
68
+ LlmRequestInterceptOutcome,
69
+ LlmSanitizeRequestCallback,
70
+ LlmSanitizeResponseCallback,
71
+ LlmStreamExecutionCallback,
72
+ LlmStreamNext,
73
+ PendingMarkSpec,
74
+ PluginContext,
75
+ PluginRuntime,
76
+ ScopeType,
77
+ SubscriberCallback,
78
+ ToolConditionalCallback,
79
+ ToolExecutionCallback,
80
+ ToolExecutionInterceptOutcome,
81
+ ToolNext,
82
+ ToolRequestCallback,
83
+ ToolSanitizeCallback,
84
+ WorkerPlugin,
85
+ WorkerSdkError,
86
+ serve_plugin,
87
+ )
88
+
89
+ __all__ = [
90
+ "AnnotatedLlmRequest",
91
+ "ConfigDiagnostic",
92
+ "DiagnosticLevel",
93
+ "Event",
94
+ "Json",
95
+ "LlmConditionalCallback",
96
+ "LlmExecutionCallback",
97
+ "LlmNext",
98
+ "LlmRequest",
99
+ "LlmRequestCallback",
100
+ "LlmRequestInterceptOutcome",
101
+ "LlmSanitizeRequestCallback",
102
+ "LlmSanitizeResponseCallback",
103
+ "LlmStreamNext",
104
+ "LlmStreamExecutionCallback",
105
+ "PluginContext",
106
+ "PluginRuntime",
107
+ "PendingMarkSpec",
108
+ "ScopeType",
109
+ "SubscriberCallback",
110
+ "ToolConditionalCallback",
111
+ "ToolExecutionCallback",
112
+ "ToolExecutionInterceptOutcome",
113
+ "ToolNext",
114
+ "ToolRequestCallback",
115
+ "ToolSanitizeCallback",
116
+ "WorkerPlugin",
117
+ "WorkerSdkError",
118
+ "serve_plugin",
119
+ ]