figuard-langchain 1.1.2__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,58 @@
1
+ HELP.md
2
+ target/
3
+ .mvn/wrapper/maven-wrapper.jar
4
+ !**/src/main/**/target/
5
+ !**/src/test/**/target/
6
+
7
+ ### STS ###
8
+ .apt_generated
9
+ .classpath
10
+ .factorypath
11
+ .project
12
+ .settings
13
+ .springBeans
14
+ .sts4-cache
15
+
16
+ ### IntelliJ IDEA ###
17
+ .idea
18
+ *.iws
19
+ *.iml
20
+ *.ipr
21
+
22
+ ### NetBeans ###
23
+ /nbproject/private/
24
+ /nbbuild/
25
+ /dist/
26
+ /nbdist/
27
+ /.nb-gradle/
28
+ build/
29
+ !**/src/main/**/build/
30
+ !**/src/test/**/build/
31
+
32
+ ### VS Code ###
33
+ .vscode/
34
+
35
+ ### Build artifacts ###
36
+
37
+ ### Planning docs (never push) ###
38
+ figuard-dayplan.md
39
+ agent-billing-sdk-spec.md
40
+ PRERELEASE_CHECKLIST.md
41
+
42
+ ### Competitive/positioning docs (not ready to publish) ###
43
+ docs/figuard-vs-stripe-agent-toolkit.md
44
+ docs/figuard-vs-payman.md
45
+
46
+ ### Python build artifacts ###
47
+ sdk/python/dist/
48
+ sdk/python/build/
49
+ sdk/python/*.egg-info/
50
+ sdk/python/**/__pycache__/
51
+ sdk/python/.pytest_cache/
52
+ *.pyc
53
+ *.pyo
54
+
55
+ ### macOS ###
56
+ .DS_Store
57
+ demo.cast
58
+ demo.gif
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: figuard-langchain
3
+ Version: 1.1.2
4
+ Summary: FiGuard pre-flight spend authorization for LangChain agents
5
+ Project-URL: Homepage, https://figuard.io
6
+ Project-URL: Repository, https://github.com/figuard/figuard-core
7
+ Project-URL: Documentation, https://figuard.io/docs
8
+ License: Apache-2.0
9
+ Keywords: ai-agents,budget-enforcement,guardrails,langchain,spend-control
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.9
20
+ Requires-Dist: figuard[langchain]>=1.1.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # figuard-langchain
24
+
25
+ Pre-flight spend authorization for LangChain agents. One line to add budget enforcement and velocity controls to any AgentExecutor.
26
+
27
+ ```bash
28
+ pip install figuard-langchain
29
+ ```
30
+
31
+ ## Quick start
32
+
33
+ ```python
34
+ from figuard_langchain import auto_guard_langchain
35
+
36
+ # Monetary budget — enforces dollar spend on tools with an "amount" parameter
37
+ executor = auto_guard_langchain(executor, budget=500)
38
+
39
+ # Velocity control — catches runaway loops even when tools have no dollar amount
40
+ executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)
41
+
42
+ result = executor.invoke({"input": "Book a flight to NYC"})
43
+ ```
44
+
45
+ `auto_guard_langchain` creates a FiGuard budget, wires a callback handler to the executor, and returns the same executor ready to run. Uses the [shared public sandbox](https://figuard-sandbox-g1ha.onrender.com/ui) by default — no account required.
46
+
47
+ ## What gets enforced
48
+
49
+ | Scenario | How to enforce |
50
+ |---|---|
51
+ | Tools with dollar amounts (`price`, `cost`, `amount` fields) | `budget=500` — denies when total spend exceeds $500 |
52
+ | Research agents, code agents, any tool without a financial parameter | `velocity_max_per_minute=10` — denies the 11th call in 60 seconds |
53
+ | Both | Pass both params — monetary ceiling + loop detection |
54
+
55
+ ## OTEL / Langfuse integration
56
+
57
+ FiGuard emits authorization spans to any OpenTelemetry backend automatically when one is configured. With Langfuse:
58
+
59
+ ```python
60
+ from langfuse import Langfuse
61
+ from figuard_langchain import auto_guard_langchain
62
+
63
+ lf = Langfuse(public_key="...", host="https://us.cloud.langfuse.com")
64
+ executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)
65
+ ```
66
+
67
+ Every `authorize()` call appears as a `GUARDRAIL` span in the Langfuse trace. Denied calls appear as `ERROR` spans — visible in the execution graph without any extra configuration.
68
+
69
+ ## Full control
70
+
71
+ For advanced fleet patterns, delegation tokens, or per-category allocations, use the main `figuard` package directly:
72
+
73
+ ```bash
74
+ pip install figuard[langchain]
75
+ ```
76
+
77
+ ```python
78
+ from figuard import FiGuardClient
79
+ from figuard.integrations.langchain import FiGuardCallbackHandler
80
+
81
+ client = FiGuardClient()
82
+ budget = client.create_budget(
83
+ user_id="alice",
84
+ total_limit=500.00,
85
+ currency="USD",
86
+ velocity_max_per_minute=10,
87
+ allocations=[
88
+ {"category": "flights", "limit": 300.00, "mode": "CATEGORY_CONSTRAINED"},
89
+ {"category": "hotels", "limit": 200.00, "mode": "CATEGORY_CONSTRAINED"},
90
+ ],
91
+ )
92
+ handler = FiGuardCallbackHandler(
93
+ client=client,
94
+ session_token=budget.primary_token.session_token,
95
+ )
96
+ executor.callbacks = [handler]
97
+ ```
98
+
99
+ ## Self-hosting
100
+
101
+ ```bash
102
+ git clone https://github.com/figuard/figuard-core
103
+ cd figuard-core
104
+ docker compose up -d
105
+ ```
106
+
107
+ Set `FIGUARD_BASE_URL=http://localhost:8080` and `FIGUARD_API_KEY=<your-key>` before running your agent.
108
+
109
+ ## Links
110
+
111
+ - [GitHub](https://github.com/figuard/figuard-core)
112
+ - [Documentation](https://figuard.io/docs)
113
+ - [Public sandbox](https://figuard-sandbox-g1ha.onrender.com/ui)
114
+ - [PyPI (figuard)](https://pypi.org/project/figuard/)
@@ -0,0 +1,92 @@
1
+ # figuard-langchain
2
+
3
+ Pre-flight spend authorization for LangChain agents. One line to add budget enforcement and velocity controls to any AgentExecutor.
4
+
5
+ ```bash
6
+ pip install figuard-langchain
7
+ ```
8
+
9
+ ## Quick start
10
+
11
+ ```python
12
+ from figuard_langchain import auto_guard_langchain
13
+
14
+ # Monetary budget — enforces dollar spend on tools with an "amount" parameter
15
+ executor = auto_guard_langchain(executor, budget=500)
16
+
17
+ # Velocity control — catches runaway loops even when tools have no dollar amount
18
+ executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)
19
+
20
+ result = executor.invoke({"input": "Book a flight to NYC"})
21
+ ```
22
+
23
+ `auto_guard_langchain` creates a FiGuard budget, wires a callback handler to the executor, and returns the same executor ready to run. Uses the [shared public sandbox](https://figuard-sandbox-g1ha.onrender.com/ui) by default — no account required.
24
+
25
+ ## What gets enforced
26
+
27
+ | Scenario | How to enforce |
28
+ |---|---|
29
+ | Tools with dollar amounts (`price`, `cost`, `amount` fields) | `budget=500` — denies when total spend exceeds $500 |
30
+ | Research agents, code agents, any tool without a financial parameter | `velocity_max_per_minute=10` — denies the 11th call in 60 seconds |
31
+ | Both | Pass both params — monetary ceiling + loop detection |
32
+
33
+ ## OTEL / Langfuse integration
34
+
35
+ FiGuard emits authorization spans to any OpenTelemetry backend automatically when one is configured. With Langfuse:
36
+
37
+ ```python
38
+ from langfuse import Langfuse
39
+ from figuard_langchain import auto_guard_langchain
40
+
41
+ lf = Langfuse(public_key="...", host="https://us.cloud.langfuse.com")
42
+ executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)
43
+ ```
44
+
45
+ Every `authorize()` call appears as a `GUARDRAIL` span in the Langfuse trace. Denied calls appear as `ERROR` spans — visible in the execution graph without any extra configuration.
46
+
47
+ ## Full control
48
+
49
+ For advanced fleet patterns, delegation tokens, or per-category allocations, use the main `figuard` package directly:
50
+
51
+ ```bash
52
+ pip install figuard[langchain]
53
+ ```
54
+
55
+ ```python
56
+ from figuard import FiGuardClient
57
+ from figuard.integrations.langchain import FiGuardCallbackHandler
58
+
59
+ client = FiGuardClient()
60
+ budget = client.create_budget(
61
+ user_id="alice",
62
+ total_limit=500.00,
63
+ currency="USD",
64
+ velocity_max_per_minute=10,
65
+ allocations=[
66
+ {"category": "flights", "limit": 300.00, "mode": "CATEGORY_CONSTRAINED"},
67
+ {"category": "hotels", "limit": 200.00, "mode": "CATEGORY_CONSTRAINED"},
68
+ ],
69
+ )
70
+ handler = FiGuardCallbackHandler(
71
+ client=client,
72
+ session_token=budget.primary_token.session_token,
73
+ )
74
+ executor.callbacks = [handler]
75
+ ```
76
+
77
+ ## Self-hosting
78
+
79
+ ```bash
80
+ git clone https://github.com/figuard/figuard-core
81
+ cd figuard-core
82
+ docker compose up -d
83
+ ```
84
+
85
+ Set `FIGUARD_BASE_URL=http://localhost:8080` and `FIGUARD_API_KEY=<your-key>` before running your agent.
86
+
87
+ ## Links
88
+
89
+ - [GitHub](https://github.com/figuard/figuard-core)
90
+ - [Documentation](https://figuard.io/docs)
91
+ - [Public sandbox](https://figuard-sandbox-g1ha.onrender.com/ui)
92
+ - [PyPI (figuard)](https://pypi.org/project/figuard/)
@@ -0,0 +1,30 @@
1
+ """
2
+ figuard-langchain — FiGuard pre-flight spend authorization for LangChain agents.
3
+
4
+ This package re-exports the LangChain integration from the main ``figuard`` package.
5
+ Install with ``pip install figuard-langchain`` for a LangChain-specific dependency,
6
+ or ``pip install figuard[langchain]`` if you already use the FiGuard SDK.
7
+
8
+ Quick start::
9
+
10
+ from figuard_langchain import auto_guard_langchain
11
+
12
+ executor = auto_guard_langchain(executor, budget=500)
13
+ result = executor.invoke({"input": "Book a flight to NYC"})
14
+
15
+ With velocity control (catches runaway loops even when tools have no dollar amount)::
16
+
17
+ executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)
18
+ """
19
+
20
+ from figuard.integrations.langchain import (
21
+ FiGuardCallbackHandler,
22
+ FiGuardToolGuard,
23
+ auto_guard_langchain,
24
+ )
25
+
26
+ __all__ = [
27
+ "FiGuardCallbackHandler",
28
+ "FiGuardToolGuard",
29
+ "auto_guard_langchain",
30
+ ]
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "figuard-langchain"
7
+ version = "1.1.2"
8
+ description = "FiGuard pre-flight spend authorization for LangChain agents"
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ requires-python = ">=3.9"
12
+ keywords = ["langchain", "ai-agents", "spend-control", "budget-enforcement", "guardrails"]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ ]
24
+ dependencies = [
25
+ "figuard[langchain]>=1.1.0",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://figuard.io"
30
+ Repository = "https://github.com/figuard/figuard-core"
31
+ Documentation = "https://figuard.io/docs"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["figuard_langchain"]