-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.py
More file actions
65 lines (54 loc) · 1.48 KB
/
entrypoint.py
File metadata and controls
65 lines (54 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from fastapi import FastAPI
from decimal import Decimal
from src.adapters import (
OpenAILLMAdapter,
InMemoryStorageAdapter,
MockExecutionAdapter,
InMemoryAuditAdapter,
)
from src.core.policy import (
PolicyEngine,
AmountLimitRule,
CategoryRestrictionRule,
ApprovalThresholdRule,
VelocityLimitRule,
)
from src.core.payments.service import PaymentService
from src.apis.fastapi.v1 import AgenticPaymentAPIRouter
app = FastAPI(title="Safe Agentic Payment API")
# Initialize adapters
llm_adapter = OpenAILLMAdapter()
storage_adapter = InMemoryStorageAdapter()
execution_adapter = MockExecutionAdapter()
audit_adapter = InMemoryAuditAdapter()
# Initialize core
policy_engine = PolicyEngine(
rules=[
AmountLimitRule(max_amount=Decimal("10000")),
CategoryRestrictionRule(
blocked_categories=[
"gambling",
"crypto",
"nsfw",
"web3",
]
),
ApprovalThresholdRule(threshold=Decimal("5000")),
VelocityLimitRule(max_per_hour=5),
]
)
payments_service = PaymentService(
llm=llm_adapter,
policy_engine=policy_engine,
audit=audit_adapter,
storage=storage_adapter,
execution=execution_adapter,
)
# Initialize API routers
agentic_payment_router = AgenticPaymentAPIRouter(payment_service=payments_service)
# Mount routers
app.include_router(
agentic_payment_router.router,
prefix="/api/v1",
tags=["agentic-payment"],
)