quantumflow-sdk 0.1.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.
Files changed (60) hide show
  1. api/__init__.py +1 -0
  2. api/auth.py +208 -0
  3. api/main.py +403 -0
  4. api/models.py +137 -0
  5. api/routes/__init__.py +1 -0
  6. api/routes/auth_routes.py +234 -0
  7. api/routes/teleport_routes.py +415 -0
  8. db/__init__.py +15 -0
  9. db/crud.py +319 -0
  10. db/database.py +93 -0
  11. db/models.py +197 -0
  12. quantumflow/__init__.py +47 -0
  13. quantumflow/algorithms/__init__.py +48 -0
  14. quantumflow/algorithms/compression/__init__.py +7 -0
  15. quantumflow/algorithms/compression/amplitude_amplification.py +189 -0
  16. quantumflow/algorithms/compression/qft_compression.py +133 -0
  17. quantumflow/algorithms/compression/token_compression.py +261 -0
  18. quantumflow/algorithms/cryptography/__init__.py +6 -0
  19. quantumflow/algorithms/cryptography/qkd.py +205 -0
  20. quantumflow/algorithms/cryptography/qrng.py +231 -0
  21. quantumflow/algorithms/machine_learning/__init__.py +7 -0
  22. quantumflow/algorithms/machine_learning/qnn.py +276 -0
  23. quantumflow/algorithms/machine_learning/qsvm.py +249 -0
  24. quantumflow/algorithms/machine_learning/vqe.py +229 -0
  25. quantumflow/algorithms/optimization/__init__.py +7 -0
  26. quantumflow/algorithms/optimization/grover.py +223 -0
  27. quantumflow/algorithms/optimization/qaoa.py +251 -0
  28. quantumflow/algorithms/optimization/quantum_annealing.py +237 -0
  29. quantumflow/algorithms/utility/__init__.py +6 -0
  30. quantumflow/algorithms/utility/circuit_optimizer.py +194 -0
  31. quantumflow/algorithms/utility/error_correction.py +330 -0
  32. quantumflow/api/__init__.py +1 -0
  33. quantumflow/api/routes/__init__.py +4 -0
  34. quantumflow/api/routes/billing_routes.py +520 -0
  35. quantumflow/backends/__init__.py +33 -0
  36. quantumflow/backends/base_backend.py +184 -0
  37. quantumflow/backends/braket_backend.py +345 -0
  38. quantumflow/backends/ibm_backend.py +112 -0
  39. quantumflow/backends/simulator_backend.py +86 -0
  40. quantumflow/billing/__init__.py +25 -0
  41. quantumflow/billing/models.py +126 -0
  42. quantumflow/billing/stripe_service.py +619 -0
  43. quantumflow/core/__init__.py +12 -0
  44. quantumflow/core/entanglement.py +164 -0
  45. quantumflow/core/memory.py +147 -0
  46. quantumflow/core/quantum_backprop.py +394 -0
  47. quantumflow/core/quantum_compressor.py +309 -0
  48. quantumflow/core/teleportation.py +386 -0
  49. quantumflow/integrations/__init__.py +107 -0
  50. quantumflow/integrations/autogen_tools.py +501 -0
  51. quantumflow/integrations/crewai_agents.py +425 -0
  52. quantumflow/integrations/crewai_tools.py +407 -0
  53. quantumflow/integrations/langchain_memory.py +385 -0
  54. quantumflow/integrations/langchain_tools.py +366 -0
  55. quantumflow/integrations/mcp_server.py +575 -0
  56. quantumflow_sdk-0.1.0.dist-info/METADATA +190 -0
  57. quantumflow_sdk-0.1.0.dist-info/RECORD +60 -0
  58. quantumflow_sdk-0.1.0.dist-info/WHEEL +5 -0
  59. quantumflow_sdk-0.1.0.dist-info/entry_points.txt +2 -0
  60. quantumflow_sdk-0.1.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,86 @@
1
+ """
2
+ Simulator Backend - Local quantum simulator using Qiskit Aer.
3
+ """
4
+
5
+ import time
6
+ from typing import Optional
7
+ import numpy as np
8
+ from qiskit import QuantumCircuit, transpile
9
+ from qiskit_aer import AerSimulator
10
+ from qiskit.quantum_info import Statevector
11
+
12
+ from quantumflow.backends.base_backend import (
13
+ QuantumBackend,
14
+ BackendType,
15
+ ExecutionResult,
16
+ )
17
+
18
+
19
+ class SimulatorBackend(QuantumBackend):
20
+ """Local quantum simulator using Qiskit Aer."""
21
+
22
+ def __init__(self, method: str = "statevector", noise_model: Optional[object] = None):
23
+ super().__init__(BackendType.SIMULATOR)
24
+ self.method = method
25
+ self.noise_model = noise_model
26
+ self._simulator: Optional[AerSimulator] = None
27
+ self._max_qubits = 30
28
+
29
+ def connect(self) -> bool:
30
+ try:
31
+ self._simulator = AerSimulator(method=self.method)
32
+ if self.noise_model:
33
+ self._simulator.set_options(noise_model=self.noise_model)
34
+ self._is_connected = True
35
+ return True
36
+ except Exception as e:
37
+ raise ConnectionError(f"Failed to initialize simulator: {e}")
38
+
39
+ def disconnect(self) -> None:
40
+ self._simulator = None
41
+ self._is_connected = False
42
+
43
+ def execute(
44
+ self,
45
+ circuit: QuantumCircuit,
46
+ shots: int = 1024,
47
+ optimization_level: int = 1,
48
+ ) -> ExecutionResult:
49
+ if not self._is_connected:
50
+ self.connect()
51
+
52
+ self.validate_circuit(circuit)
53
+ start_time = time.perf_counter()
54
+
55
+ # Get statevector if no measurements
56
+ has_measurements = any(inst.operation.name == "measure" for inst in circuit.data)
57
+ statevector = None if has_measurements else self.get_statevector(circuit)
58
+
59
+ # Add measurements for sampling
60
+ exec_circuit = circuit.copy()
61
+ if not has_measurements:
62
+ exec_circuit.measure_all()
63
+
64
+ transpiled = transpile(exec_circuit, self._simulator, optimization_level=optimization_level)
65
+ job = self._simulator.run(transpiled, shots=shots)
66
+ counts = job.result().get_counts()
67
+
68
+ return ExecutionResult(
69
+ counts=counts,
70
+ statevector=statevector,
71
+ shots=shots,
72
+ backend_name="aer_simulator",
73
+ execution_time_ms=(time.perf_counter() - start_time) * 1000,
74
+ fidelity=1.0,
75
+ )
76
+
77
+ def get_statevector(self, circuit: QuantumCircuit) -> np.ndarray:
78
+ return Statevector(circuit).data
79
+
80
+ @property
81
+ def max_qubits(self) -> int:
82
+ return self._max_qubits
83
+
84
+ @property
85
+ def is_simulator(self) -> bool:
86
+ return True
@@ -0,0 +1,25 @@
1
+ """QuantumFlow Billing - Stripe integration for subscriptions and usage billing."""
2
+
3
+ from quantumflow.billing.stripe_service import (
4
+ StripeService,
5
+ SubscriptionTier,
6
+ TIER_PRICES,
7
+ TIER_LIMITS,
8
+ )
9
+ from quantumflow.billing.models import (
10
+ Customer,
11
+ Subscription,
12
+ Invoice,
13
+ UsageRecord,
14
+ )
15
+
16
+ __all__ = [
17
+ "StripeService",
18
+ "SubscriptionTier",
19
+ "TIER_PRICES",
20
+ "TIER_LIMITS",
21
+ "Customer",
22
+ "Subscription",
23
+ "Invoice",
24
+ "UsageRecord",
25
+ ]
@@ -0,0 +1,126 @@
1
+ """Billing data models for Stripe integration."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from datetime import datetime
5
+ from enum import Enum
6
+ from typing import Optional
7
+
8
+
9
+ class SubscriptionStatus(str, Enum):
10
+ """Stripe subscription statuses."""
11
+ ACTIVE = "active"
12
+ PAST_DUE = "past_due"
13
+ CANCELED = "canceled"
14
+ UNPAID = "unpaid"
15
+ TRIALING = "trialing"
16
+ INCOMPLETE = "incomplete"
17
+ INCOMPLETE_EXPIRED = "incomplete_expired"
18
+ PAUSED = "paused"
19
+
20
+
21
+ class PaymentStatus(str, Enum):
22
+ """Payment/Invoice statuses."""
23
+ DRAFT = "draft"
24
+ OPEN = "open"
25
+ PAID = "paid"
26
+ VOID = "void"
27
+ UNCOLLECTIBLE = "uncollectible"
28
+
29
+
30
+ @dataclass
31
+ class Customer:
32
+ """Stripe customer representation."""
33
+ id: str
34
+ email: str
35
+ name: Optional[str] = None
36
+ stripe_customer_id: Optional[str] = None
37
+ default_payment_method: Optional[str] = None
38
+ created_at: datetime = field(default_factory=datetime.utcnow)
39
+ metadata: dict = field(default_factory=dict)
40
+
41
+ @property
42
+ def has_payment_method(self) -> bool:
43
+ return self.default_payment_method is not None
44
+
45
+
46
+ @dataclass
47
+ class Subscription:
48
+ """Stripe subscription representation."""
49
+ id: str
50
+ customer_id: str
51
+ stripe_subscription_id: str
52
+ tier: str
53
+ status: SubscriptionStatus
54
+ current_period_start: datetime
55
+ current_period_end: datetime
56
+ cancel_at_period_end: bool = False
57
+ canceled_at: Optional[datetime] = None
58
+ trial_end: Optional[datetime] = None
59
+ created_at: datetime = field(default_factory=datetime.utcnow)
60
+ metadata: dict = field(default_factory=dict)
61
+
62
+ @property
63
+ def is_active(self) -> bool:
64
+ return self.status in {SubscriptionStatus.ACTIVE, SubscriptionStatus.TRIALING}
65
+
66
+ @property
67
+ def days_remaining(self) -> int:
68
+ if self.current_period_end:
69
+ delta = self.current_period_end - datetime.utcnow()
70
+ return max(0, delta.days)
71
+ return 0
72
+
73
+
74
+ @dataclass
75
+ class Invoice:
76
+ """Stripe invoice representation."""
77
+ id: str
78
+ customer_id: str
79
+ stripe_invoice_id: str
80
+ subscription_id: Optional[str]
81
+ amount_due: int # in cents
82
+ amount_paid: int
83
+ currency: str
84
+ status: PaymentStatus
85
+ invoice_pdf: Optional[str] = None
86
+ hosted_invoice_url: Optional[str] = None
87
+ period_start: Optional[datetime] = None
88
+ period_end: Optional[datetime] = None
89
+ created_at: datetime = field(default_factory=datetime.utcnow)
90
+
91
+ @property
92
+ def amount_due_dollars(self) -> float:
93
+ return self.amount_due / 100
94
+
95
+ @property
96
+ def amount_paid_dollars(self) -> float:
97
+ return self.amount_paid / 100
98
+
99
+
100
+ @dataclass
101
+ class UsageRecord:
102
+ """Usage record for metered billing."""
103
+ id: str
104
+ subscription_id: str
105
+ quantity: int # API calls
106
+ timestamp: datetime
107
+ action: str = "increment" # or "set"
108
+ idempotency_key: Optional[str] = None
109
+ metadata: dict = field(default_factory=dict)
110
+
111
+
112
+ @dataclass
113
+ class PriceInfo:
114
+ """Pricing information for a tier."""
115
+ tier: str
116
+ stripe_price_id: str
117
+ amount: int # monthly price in cents
118
+ stripe_product_id: str = ""
119
+ currency: str = "usd"
120
+ interval: str = "month"
121
+ api_calls_included: int = 0
122
+ overage_price_per_call: float = 0.0 # in cents
123
+
124
+ @property
125
+ def monthly_price_dollars(self) -> float:
126
+ return self.amount / 100