causum 0.1.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.
Files changed (35) hide show
  1. causum-0.1.0/LICENSE +7 -0
  2. causum-0.1.0/PKG-INFO +393 -0
  3. causum-0.1.0/README.md +342 -0
  4. causum-0.1.0/causum/__init__.py +50 -0
  5. causum-0.1.0/causum/adapters/__init__.py +116 -0
  6. causum-0.1.0/causum/adapters/base.py +225 -0
  7. causum-0.1.0/causum/adapters/clickhouse.py +207 -0
  8. causum-0.1.0/causum/adapters/mongodb.py +511 -0
  9. causum-0.1.0/causum/adapters/mysql.py +242 -0
  10. causum-0.1.0/causum/adapters/postgres.py +251 -0
  11. causum-0.1.0/causum/adapters/sqlalchemy_adapter.py +400 -0
  12. causum-0.1.0/causum/adapters/timescaledb.py +216 -0
  13. causum-0.1.0/causum/cache.py +273 -0
  14. causum-0.1.0/causum/client.py +695 -0
  15. causum-0.1.0/causum/config.py +232 -0
  16. causum-0.1.0/causum/examples/direct_queries.py +22 -0
  17. causum-0.1.0/causum/examples/prompt_usage.py +196 -0
  18. causum-0.1.0/causum/examples/sqlalchemy_databases.py +395 -0
  19. causum-0.1.0/causum/examples/standalone.py +124 -0
  20. causum-0.1.0/causum/examples/test_mongo_connection.py +84 -0
  21. causum-0.1.0/causum/exceptions.py +68 -0
  22. causum-0.1.0/causum/governance/__init__.py +8 -0
  23. causum-0.1.0/causum/governance/client.py +241 -0
  24. causum-0.1.0/causum/governance/metadata.py +202 -0
  25. causum-0.1.0/causum/parsers/__init__.py +8 -0
  26. causum-0.1.0/causum/parsers/mongo_parser.py +294 -0
  27. causum-0.1.0/causum/parsers/sql_parser.py +220 -0
  28. causum-0.1.0/causum/tests/__init__.py +0 -0
  29. causum-0.1.0/causum.egg-info/PKG-INFO +393 -0
  30. causum-0.1.0/causum.egg-info/SOURCES.txt +33 -0
  31. causum-0.1.0/causum.egg-info/dependency_links.txt +1 -0
  32. causum-0.1.0/causum.egg-info/requires.txt +29 -0
  33. causum-0.1.0/causum.egg-info/top_level.txt +1 -0
  34. causum-0.1.0/pyproject.toml +85 -0
  35. causum-0.1.0/setup.cfg +4 -0
causum-0.1.0/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Enter Growl LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
causum-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,393 @@
1
+ Metadata-Version: 2.4
2
+ Name: causum
3
+ Version: 0.1.0
4
+ Summary: Causum™ API client for RAG/data systems with built-in governance and metadata capture
5
+ Author-email: Causum <support@causum.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://gitlab.com/causum/causum-py.git
8
+ Project-URL: Documentation, https://gitlab.com/causum/causum-py.git#readme
9
+ Project-URL: Repository, https://gitlab.com/causum/causum-py.git
10
+ Project-URL: Issues, https://gitlab.com/causum/causum-py.git/issues
11
+ Keywords: causum,api,rag,langchain,llamaindex,governance,metadata
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Database
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pydantic>=2.0
26
+ Requires-Dist: psycopg2-binary>=2.9
27
+ Requires-Dist: asyncpg>=0.29
28
+ Requires-Dist: mysql-connector-python>=8.0
29
+ Requires-Dist: clickhouse-driver>=0.2
30
+ Requires-Dist: pymongo>=4.0
31
+ Requires-Dist: motor>=3.0
32
+ Requires-Dist: sqlglot>=20.0
33
+ Requires-Dist: httpx>=0.25
34
+ Requires-Dist: diskcache>=5.6
35
+ Requires-Dist: python-dotenv>=1.0
36
+ Requires-Dist: sqlalchemy>=2.0
37
+ Provides-Extra: langchain
38
+ Requires-Dist: langchain>=0.1.0; extra == "langchain"
39
+ Provides-Extra: llamaindex
40
+ Requires-Dist: llama-index>=0.9.0; extra == "llamaindex"
41
+ Provides-Extra: all
42
+ Requires-Dist: langchain>=0.1.0; extra == "all"
43
+ Requires-Dist: llama-index>=0.9.0; extra == "all"
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=7.0; extra == "dev"
46
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
47
+ Requires-Dist: black>=23.0; extra == "dev"
48
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
49
+ Requires-Dist: mypy>=1.0; extra == "dev"
50
+ Dynamic: license-file
51
+
52
+ # Causum™ API
53
+
54
+ **Universal Database Client for NL→Query and RAG Systems with Built-in Governance**
55
+
56
+ `causum` is a unified database client designed for NL→Query and RAG (Retrieval-Augmented Generation) systems. It provides a single interface to query multiple database types while embedding causality for advanced automations, governance, and compliance.
57
+
58
+ ## Features
59
+
60
+ ✅ **Framework Integrations** - Works with LangChain, LlamaIndex, and standalone
61
+ ✅ **Built-in Governance** - Validation rules, real-time feedback, compliance trails
62
+ ✅ **RAG-Optimized** - Causal inference, deeper and more precise insights
63
+ ✅ **Framework Integrations** - Works with LangChain, LlamaIndex, and standalone
64
+ ✅ **Query Semantics** - Currently supporting 55 databases
65
+ ✅ **Type-Safe** - Full type hints and Pydantic models
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ # Basic installation
71
+ pip install causum
72
+
73
+ # With LangChain support
74
+ pip install causum[langchain]
75
+
76
+ # With LlamaIndex support
77
+ pip install causum[llamaindex]
78
+
79
+ # With all integrations
80
+ pip install causum[all]
81
+ ```
82
+
83
+ ## Quick Start
84
+
85
+ ### 1. Set up your profiles
86
+
87
+ Create a `profiles.json` file:
88
+
89
+ ```json
90
+ {
91
+ "profiles": {
92
+ "postgres_db": {
93
+ "type": "postgres",
94
+ "host": "localhost",
95
+ "port": 5432,
96
+ "database": "mydb",
97
+ "username": "user",
98
+ "password": "${POSTGRES_PASSWORD}"
99
+ },
100
+ "mongo_db": {
101
+ "type": "mongodb",
102
+ "host": "localhost",
103
+ "port": 27017,
104
+ "database": "mydb"
105
+ }
106
+ },
107
+ "global": {
108
+ "governance_url": "http://localhost:5000/metadata",
109
+ "enable_cache": true,
110
+ "cache_ttl": 300
111
+ }
112
+ }
113
+ ```
114
+
115
+ ### 2. Set your API key
116
+
117
+ ```bash
118
+ export CAUSUM_API_KEY="your-api-key-here"
119
+ ```
120
+
121
+ ### 3. Use the client
122
+
123
+ ```python
124
+ from causum import UniversalClient
125
+
126
+ # Initialize
127
+ client = UniversalClient(profiles_path="./profiles.json")
128
+
129
+ # Query PostgreSQL
130
+ result = client.execute(
131
+ profile="postgres_db",
132
+ query="SELECT * FROM patients LIMIT 10"
133
+ )
134
+
135
+ print(result['data'])
136
+ print(result['metadata'])
137
+
138
+ # Query MongoDB
139
+ result = client.execute(
140
+ profile="mongo_db",
141
+ query='db.users.find({"age": {"$gt": 25}})'
142
+ )
143
+
144
+ # Clean up
145
+ client.close()
146
+ ```
147
+
148
+ ## Supported Databases
149
+
150
+ causum supports **50+ databases** through a combination of optimized native adapters and SQLAlchemy integration:
151
+
152
+ ### Native Adapters (Optimized Performance)
153
+
154
+ | Database | Type String | Status |
155
+ |----------|-------------|--------|
156
+ | PostgreSQL | `postgres`, `postgresql` | ✅ Native |
157
+ | MySQL | `mysql` | ✅ Native |
158
+ | MongoDB | `mongodb`, `mongo` | ✅ Native |
159
+ | ClickHouse | `clickhouse` | ✅ Native |
160
+ | TimescaleDB | `timescaledb`, `timescale` | ✅ Native |
161
+
162
+ ### SQLAlchemy Adapter (50+ Databases)
163
+
164
+ **Cloud Data Warehouses:**
165
+ - Snowflake (`snowflake`)
166
+ - Amazon Redshift (`redshift`)
167
+ - Google BigQuery (`bigquery`)
168
+ - Databricks SQL (`databricks`)
169
+ - Azure Synapse (`mssql`)
170
+
171
+ **Traditional RDBMS:**
172
+ - Oracle Database (`oracle`)
173
+ - Microsoft SQL Server (`mssql`, `sqlserver`)
174
+ - IBM DB2 (`db2`)
175
+ - SQLite (`sqlite`)
176
+ - Firebird (`firebird`)
177
+ - Sybase (`sybase`)
178
+
179
+ **Big Data / Analytics:**
180
+ - Apache Hive (`hive`)
181
+ - Apache Impala (`impala`)
182
+ - Presto (`presto`)
183
+ - Trino (`trino`)
184
+ - Amazon Athena (`athena`)
185
+ - Apache Drill (`drill`)
186
+
187
+ **Specialized:**
188
+ - Teradata (`teradata`)
189
+ - Vertica (`vertica`)
190
+ - And many more...
191
+
192
+ **Usage Example:**
193
+ ```python
194
+ # Any SQLAlchemy-supported database works out of the box
195
+ profiles = {
196
+ "snowflake_dwh": {
197
+ "type": "snowflake",
198
+ "host": "account.snowflakecomputing.com",
199
+ "database": "analytics",
200
+ "username": "user",
201
+ "password": "${SNOWFLAKE_PASSWORD}"
202
+ },
203
+ "oracle_erp": {
204
+ "type": "oracle",
205
+ "host": "oracle.company.com",
206
+ "port": 1521,
207
+ "database": "PROD",
208
+ "username": "app_user",
209
+ "password": "${ORACLE_PASSWORD}"
210
+ }
211
+ }
212
+ ```
213
+
214
+ ## Configuration
215
+
216
+ ### Profiles File
217
+
218
+ Profiles can be loaded from:
219
+ - `/etc/causum/profiles.json`
220
+ - `~/.causum/profiles.json`
221
+ - `./profiles.json`
222
+ - Custom path
223
+
224
+ ### Environment Variables
225
+
226
+ - `CAUSUM_API_KEY` - API key for governance service (required)
227
+ - `{DB}_PASSWORD` - Database passwords (referenced as `${DB_PASSWORD}` in profiles)
228
+
229
+ ### Programmatic Configuration
230
+
231
+ ```python
232
+ from causum import UniversalClient
233
+
234
+ client = UniversalClient(
235
+ profiles={
236
+ "my_db": {
237
+ "type": "postgres",
238
+ "host": "localhost",
239
+ "port": 5432,
240
+ "database": "mydb",
241
+ "username": "user",
242
+ "password": "secret"
243
+ }
244
+ },
245
+ governance_url="http://localhost:5000/metadata",
246
+ enable_cache=True,
247
+ fail_open=True
248
+ )
249
+ ```
250
+
251
+ ## Result Format
252
+
253
+ All queries return a standardized result dictionary:
254
+
255
+ ```python
256
+ {
257
+ "status": "success" | "error",
258
+ "data": [...], # Query results as list of dicts
259
+ "governance_response": {...}, # Response from the causal/governance API
260
+ "metadata": {
261
+ "db": "postgres",
262
+ "schema": "public.patients",
263
+ "fields": ["id", "name", "age"],
264
+ "operation": "SELECT",
265
+ "row_count": 10,
266
+ "execution_time_ms": 25.5,
267
+ "query_hash": "abc123",
268
+ "cached": false,
269
+ "truncated": false,
270
+ "timestamp": "2025-10-17T14:32:10Z"
271
+ },
272
+ "schema_info": {...}, # Optional schema information
273
+ "error": null | {
274
+ "code": "ERROR_CODE",
275
+ "message": "Error message",
276
+ "details": {...}
277
+ }
278
+ }
279
+ ```
280
+
281
+ ## Advanced Usage
282
+
283
+ ### Caching
284
+
285
+ ```python
286
+ client = UniversalClient(
287
+ profiles_path="./profiles.json",
288
+ enable_cache=True,
289
+ cache_ttl=300 # 5 minutes
290
+ )
291
+
292
+ # First call - queries database
293
+ result1 = client.execute(profile="db", query="SELECT * FROM users")
294
+
295
+ # Second call - returns cached result
296
+ result2 = client.execute(profile="db", query="SELECT * FROM users")
297
+ assert result2['metadata']['cached'] == True
298
+ ```
299
+
300
+ ### User Context
301
+
302
+ ```python
303
+ result = client.execute(
304
+ profile="postgres_db",
305
+ query="SELECT * FROM patients",
306
+ user_context={
307
+ "rag_session_id": "session-123",
308
+ "user_query": "How many patients?",
309
+ "app_name": "my-rag-app"
310
+ }
311
+ )
312
+ ```
313
+
314
+ ### Schema Introspection
315
+
316
+ ```python
317
+ # Get database schema
318
+ schema = client.get_schema("postgres_db")
319
+
320
+ for table_name, columns in schema['public'].items():
321
+ print(f"Table: {table_name}")
322
+ for col_name, col_info in columns.items():
323
+ print(f" {col_name}: {col_info['type']}")
324
+ ```
325
+
326
+ ### Context Manager
327
+
328
+ ```python
329
+ with UniversalClient(profiles_path="./profiles.json") as client:
330
+ result = client.execute(profile="db", query="SELECT 1")
331
+ # Connections automatically closed
332
+ ```
333
+
334
+ ## Framework Integrations
335
+
336
+ ### LangChain
337
+
338
+ ```python
339
+ from causum.integrations.langchain import create_db_tools
340
+ from langchain.agents import initialize_agent
341
+ from langchain.chat_models import ChatOpenAI
342
+
343
+ # Create tools from profiles
344
+ tools = create_db_tools(
345
+ profiles_path="./profiles.json",
346
+ profiles=["postgres_db", "mongo_db"]
347
+ )
348
+
349
+ # Use in agent
350
+ llm = ChatOpenAI(temperature=0)
351
+ agent = initialize_agent(tools, llm, agent="zero-shot-react-description")
352
+
353
+ response = agent.run("How many patients were admitted in 2020?")
354
+ ```
355
+
356
+ ### LlamaIndex
357
+
358
+ ```python
359
+ from causum.integrations.llamaindex import DatabaseQueryTool
360
+ from llama_index.core.agent import ReActAgent
361
+ from llama_index.llms.openai import OpenAI
362
+
363
+ # Create tool
364
+ db_tool = DatabaseQueryTool(
365
+ profile="postgres_db",
366
+ description="Query patient database"
367
+ )
368
+
369
+ # Use in agent
370
+ llm = OpenAI(model="gpt-4")
371
+ agent = ReActAgent.from_tools([db_tool], llm=llm)
372
+
373
+ response = agent.chat("What's the average age of ICU patients?")
374
+ ```
375
+
376
+ ## Contributing
377
+
378
+ Contributions are welcome! Please:
379
+
380
+ 1. Fork the repository
381
+ 2. Create a feature branch
382
+ 3. Make your changes with tests
383
+ 4. Submit a pull request
384
+
385
+ ## License
386
+
387
+ MIT License - see LICENSE file for details
388
+
389
+ ## Support
390
+
391
+ - Documentation: [GitHub README](https://gitlab.com/causum/causum-py.git)
392
+ - Issues: [GitHub Issues](https://gitlab.com/causum/causum-py.git/issues)
393
+ - Email: support@causum.com