maigp-semantic-kernel 1.0.0__tar.gz
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,56 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.venv/
|
|
8
|
+
.eggs/
|
|
9
|
+
|
|
10
|
+
# Node
|
|
11
|
+
node_modules/
|
|
12
|
+
dist/
|
|
13
|
+
|
|
14
|
+
# Go
|
|
15
|
+
bin/
|
|
16
|
+
|
|
17
|
+
# Rust
|
|
18
|
+
target/
|
|
19
|
+
|
|
20
|
+
# .NET
|
|
21
|
+
bin/
|
|
22
|
+
obj/
|
|
23
|
+
|
|
24
|
+
# Java
|
|
25
|
+
*.class
|
|
26
|
+
out/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.kiro/
|
|
32
|
+
*.swp
|
|
33
|
+
|
|
34
|
+
# OS
|
|
35
|
+
.DS_Store
|
|
36
|
+
Thumbs.db
|
|
37
|
+
|
|
38
|
+
# Secrets (never commit)
|
|
39
|
+
.env
|
|
40
|
+
*.pem
|
|
41
|
+
*.key
|
|
42
|
+
*.pdf
|
|
43
|
+
BACKLOG/
|
|
44
|
+
patent/
|
|
45
|
+
docs/.archive/
|
|
46
|
+
review/
|
|
47
|
+
|
|
48
|
+
# Generated navigable spec split — derived from the monoliths by
|
|
49
|
+
# specification/tools/spec_split.py; the manifest + monoliths are the
|
|
50
|
+
# source of truth, not this output. Same convention as Mars (spec/*/*/).
|
|
51
|
+
specification/*/*/
|
|
52
|
+
specification/split-index.md
|
|
53
|
+
|
|
54
|
+
# Local rendering/preview site — self-contained, not part of the
|
|
55
|
+
# published specification, never pushed.
|
|
56
|
+
site/
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""AIGP-Semantic-Kernel — Governed filter for Microsoft Semantic Kernel."""
|
|
2
|
+
|
|
3
|
+
__version__ = "1.0.0"
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from aigp_agent_core import AgentGovernance
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AigpFilter:
|
|
10
|
+
"""Semantic Kernel function invocation filter implementing AIGP governance.
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
from semantic_kernel import Kernel
|
|
14
|
+
from aigp_semantic_kernel import AigpFilter
|
|
15
|
+
|
|
16
|
+
aigp_filter = AigpFilter(gov_url=..., app_id="my-sk-agent", hmac_secret=...)
|
|
17
|
+
kernel.add_filter("function_invocation", aigp_filter)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, gov_url: str, app_id: str, hmac_secret: str, **kwargs):
|
|
21
|
+
self._gov = AgentGovernance(gov_url, app_id, hmac_secret, **kwargs)
|
|
22
|
+
|
|
23
|
+
async def on_function_invocation(self, context, next_handler):
|
|
24
|
+
"""SK filter — wraps function invocation with AIGP governance."""
|
|
25
|
+
fn_name = context.function.name if hasattr(context, "function") else "unknown"
|
|
26
|
+
model_id = getattr(context, "model_id", "semantic-kernel")
|
|
27
|
+
|
|
28
|
+
# Pre-invoke CHECK
|
|
29
|
+
self._gov.pre_invoke(fn_name, model_id)
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
# Execute the function
|
|
33
|
+
await next_handler(context)
|
|
34
|
+
|
|
35
|
+
# Accumulate tokens if available
|
|
36
|
+
result = context.result if hasattr(context, "result") else None
|
|
37
|
+
if result and hasattr(result, "metadata"):
|
|
38
|
+
usage = result.metadata.get("usage", {})
|
|
39
|
+
self._gov.on_model_call(usage=usage)
|
|
40
|
+
|
|
41
|
+
await self._gov.post_invoke()
|
|
42
|
+
except Exception as e:
|
|
43
|
+
await self._gov.on_error(e)
|
|
44
|
+
raise
|
|
45
|
+
|
|
46
|
+
# Alias for SK filter registration
|
|
47
|
+
__call__ = on_function_invocation
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "maigp-semantic-kernel"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "AIGP governance adapter for semantic-kernel"
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
dependencies = ["maigp-agent-core>=1.0.0"]
|
|
11
|
+
|
|
12
|
+
[tool.hatch.build.targets.wheel]
|
|
13
|
+
packages = ["aigp_semantic_kernel"]
|