hindsight-client 0.1.11__py3-none-any.whl → 0.1.13__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.
|
@@ -44,8 +44,12 @@ class Hindsight:
|
|
|
44
44
|
```python
|
|
45
45
|
from hindsight_client import Hindsight
|
|
46
46
|
|
|
47
|
+
# Without authentication
|
|
47
48
|
client = Hindsight(base_url="http://localhost:8888")
|
|
48
49
|
|
|
50
|
+
# With API key authentication
|
|
51
|
+
client = Hindsight(base_url="http://localhost:8888", api_key="your-api-key")
|
|
52
|
+
|
|
49
53
|
# Store a memory
|
|
50
54
|
client.retain(bank_id="alice", content="Alice loves AI")
|
|
51
55
|
|
|
@@ -59,15 +63,16 @@ class Hindsight:
|
|
|
59
63
|
```
|
|
60
64
|
"""
|
|
61
65
|
|
|
62
|
-
def __init__(self, base_url: str, timeout: float = 30.0):
|
|
66
|
+
def __init__(self, base_url: str, api_key: Optional[str] = None, timeout: float = 30.0):
|
|
63
67
|
"""
|
|
64
68
|
Initialize the Hindsight client.
|
|
65
69
|
|
|
66
70
|
Args:
|
|
67
71
|
base_url: The base URL of the Hindsight API server
|
|
72
|
+
api_key: Optional API key for authentication (sent as Bearer token)
|
|
68
73
|
timeout: Request timeout in seconds (default: 30.0)
|
|
69
74
|
"""
|
|
70
|
-
config = hindsight_client_api.Configuration(host=base_url)
|
|
75
|
+
config = hindsight_client_api.Configuration(host=base_url, access_token=api_key)
|
|
71
76
|
self._api_client = hindsight_client_api.ApiClient(config)
|
|
72
77
|
self._api = default_api.DefaultApi(self._api_client)
|
|
73
78
|
|
|
@@ -80,9 +85,21 @@ class Hindsight:
|
|
|
80
85
|
self.close()
|
|
81
86
|
|
|
82
87
|
def close(self):
|
|
83
|
-
"""Close the API client."""
|
|
88
|
+
"""Close the API client (sync version - use aclose() in async code)."""
|
|
89
|
+
if self._api_client:
|
|
90
|
+
try:
|
|
91
|
+
loop = asyncio.get_running_loop()
|
|
92
|
+
# We're in an async context - schedule but don't wait
|
|
93
|
+
# The caller should use aclose() instead
|
|
94
|
+
loop.create_task(self._api_client.close())
|
|
95
|
+
except RuntimeError:
|
|
96
|
+
# No running loop - safe to run synchronously
|
|
97
|
+
_run_async(self._api_client.close())
|
|
98
|
+
|
|
99
|
+
async def aclose(self):
|
|
100
|
+
"""Close the API client (async version)."""
|
|
84
101
|
if self._api_client:
|
|
85
|
-
|
|
102
|
+
await self._api_client.close()
|
|
86
103
|
|
|
87
104
|
# Simplified methods for main operations
|
|
88
105
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
hindsight_client/__init__.py,sha256=PyDJ4UVKmtRN5OeBs0-rl-tUtqS8OoX53qvejKGC3JU,3114
|
|
2
|
-
hindsight_client/hindsight_client.py,sha256=
|
|
2
|
+
hindsight_client/hindsight_client.py,sha256=ALsndRe_ogzBVtaFuyAtjtZQTWFefiehIEF_WIW8Xk8,14320
|
|
3
3
|
hindsight_client_api/__init__.py,sha256=7hfGgOu50_bmmuoz4-e4JVqubo5W39g_p3HHgaWZGRs,5941
|
|
4
4
|
hindsight_client_api/api_client.py,sha256=gO_s4kVFGPJMawvNcdoqbpqptHIIKELylVni48b7rqU,27860
|
|
5
5
|
hindsight_client_api/api_response.py,sha256=eMxw1mpmJcoGZ3gs9z6jM4oYoZ10Gjk333s9sKxGv7s,652
|
|
@@ -126,6 +126,6 @@ hindsight_client_api/test/test_retain_response.py,sha256=L_83q5aYZAb9mZhHwF7WAe4
|
|
|
126
126
|
hindsight_client_api/test/test_update_disposition_request.py,sha256=bHQG7SqMD_KESLs61kVOTknYH-flvX5UjW9yJ9UK3RI,1550
|
|
127
127
|
hindsight_client_api/test/test_validation_error.py,sha256=FiG2lcCSznxrbqRk2rcKv1ctpin0gGM5YGReZWMRnkw,1549
|
|
128
128
|
hindsight_client_api/test/test_validation_error_loc_inner.py,sha256=Cy-VdSn1aBCRzpiI-2OSCrK376C5eHDywvbF16KNhMQ,1398
|
|
129
|
-
hindsight_client-0.1.
|
|
130
|
-
hindsight_client-0.1.
|
|
131
|
-
hindsight_client-0.1.
|
|
129
|
+
hindsight_client-0.1.13.dist-info/METADATA,sha256=-50doBjnqU1_7re16GZsu9-5x33mUhaxNxyUC4uhRXw,648
|
|
130
|
+
hindsight_client-0.1.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
131
|
+
hindsight_client-0.1.13.dist-info/RECORD,,
|
|
File without changes
|