omtx 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.
omtx-0.1.0/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OMTX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
omtx-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: omtx
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the OM Gateway V2
5
+ Home-page: https://github.com/omtx/python-sdk
6
+ Author: OM Therapeutics
7
+ Author-email: OMTX <dev@omtx.ai>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 OMTX
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+
31
+
32
+ Project-URL: Homepage, https://github.com/omtx-ai/om-external
33
+ Project-URL: Issues, https://github.com/omtx-ai/om-external/issues
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Typing :: Typed
38
+ Requires-Python: >=3.8
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: requests>=2.31.0
42
+ Requires-Dist: httpx>=0.27.0
43
+ Dynamic: author
44
+ Dynamic: home-page
45
+ Dynamic: license-file
46
+ Dynamic: requires-python
47
+
48
+ # OMTX Python SDK
49
+
50
+ Simple Python client for the OM API Gateway. Generate molecular diligence reports and perform deep scientific research with just a few lines of code.
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install omtx
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ ```python
61
+ from omtx import Client
62
+
63
+ # Initialize client (uses OMTX_API_KEY environment variable)
64
+ client = Client()
65
+
66
+ # Generate a diligence report
67
+ result = client.generate_diligence("BRAF")
68
+ print(result.summary)
69
+
70
+ # Perform deep research
71
+ research = client.deep_research("CRISPR applications in cancer treatment")
72
+ print(research.final_report)
73
+
74
+ # Check available credits
75
+ credits = client.credits()
76
+ print(f"Available credits: {credits}")
77
+ ```
78
+
79
+ ## Setup
80
+
81
+ ### Get an API Key
82
+
83
+ 1. Sign up at [https://omtx.ai](https://omtx.ai)
84
+ 2. Navigate to your dashboard
85
+ 3. Generate an API key
86
+
87
+ ### Set Your API Key
88
+
89
+ #### Option 1: Environment Variable (Recommended)
90
+
91
+ ```bash
92
+ export OMTX_API_KEY="your-api-key-here"
93
+ ```
94
+
95
+ #### Option 2: Pass to Client
96
+
97
+ ```python
98
+ from omtx import Client
99
+
100
+ client = Client(api_key="your-api-key-here")
101
+ ```
102
+
103
+ ## Examples
104
+
105
+ ### Generate Diligence Report
106
+
107
+ ```python
108
+ from omtx import Client
109
+
110
+ client = Client()
111
+
112
+ # Generate report for a molecular target
113
+ result = client.generate_diligence("KRAS")
114
+
115
+ # Access the summary
116
+ print(result.summary)
117
+
118
+ # Access full report data
119
+ print(result.report_data)
120
+ ```
121
+
122
+ ### Deep Research
123
+
124
+ ```python
125
+ from omtx import Client
126
+
127
+ client = Client()
128
+
129
+ # Perform deep research on a scientific query
130
+ research = client.deep_research(
131
+ "CAR-T therapy mechanisms and recent advances",
132
+ max_iterations=5 # Optional: more iterations = deeper research
133
+ )
134
+
135
+ # View the final report
136
+ print(research.final_report)
137
+
138
+ # Access individual findings
139
+ for finding in research.findings:
140
+ print(f"- {finding['claim']}")
141
+
142
+ # Check execution time
143
+ print(f"Research completed in {research.execution_time:.1f} seconds")
144
+ ```
145
+
146
+ ### Error Handling
147
+
148
+ ```python
149
+ from omtx import Client, OMTXError, InsufficientCreditsError
150
+
151
+ client = Client()
152
+
153
+ try:
154
+ result = client.generate_diligence("BRAF")
155
+ except InsufficientCreditsError as e:
156
+ print(f"Not enough credits. Please add more credits to your account.")
157
+ except OMTXError as e:
158
+ print(f"An error occurred: {e}")
159
+ ```
160
+
161
+ ### Context Manager
162
+
163
+ ```python
164
+ from omtx import Client
165
+
166
+ # Automatically cleans up resources
167
+ with Client() as client:
168
+ result = client.generate_diligence("TP53")
169
+ print(result.summary)
170
+ ```
171
+
172
+ ## Available Methods
173
+
174
+ - `generate_diligence(target)` - Generate a comprehensive diligence report for a molecular target
175
+ - `deep_research(query, max_iterations=3)` - Perform iterative deep research on a scientific query
176
+ - `credits()` - Check available credits
177
+
178
+ ## Features
179
+
180
+ - **Simple API** - Just a few methods to remember
181
+ - **Automatic Retries** - Handles transient network errors automatically
182
+ - **Idempotency** - Safe to retry requests without double charges
183
+ - **Type Hints** - Full IDE autocomplete support
184
+ - **Error Handling** - Clear, actionable error messages
185
+
186
+ ## Requirements
187
+
188
+ - Python 3.8 or higher
189
+ - An OMTX API key
190
+
191
+ ## Support
192
+
193
+ - Email: support@omtx.ai
194
+ - Documentation: https://docs.omtx.ai
195
+ - Issues: https://github.com/omtx/python-sdk/issues
196
+
197
+ ## License
198
+
199
+ MIT License - see LICENSE file for details.
omtx-0.1.0/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # OMTX Python SDK
2
+
3
+ Simple Python client for the OM API Gateway. Generate molecular diligence reports and perform deep scientific research with just a few lines of code.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install omtx
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from omtx import Client
15
+
16
+ # Initialize client (uses OMTX_API_KEY environment variable)
17
+ client = Client()
18
+
19
+ # Generate a diligence report
20
+ result = client.generate_diligence("BRAF")
21
+ print(result.summary)
22
+
23
+ # Perform deep research
24
+ research = client.deep_research("CRISPR applications in cancer treatment")
25
+ print(research.final_report)
26
+
27
+ # Check available credits
28
+ credits = client.credits()
29
+ print(f"Available credits: {credits}")
30
+ ```
31
+
32
+ ## Setup
33
+
34
+ ### Get an API Key
35
+
36
+ 1. Sign up at [https://omtx.ai](https://omtx.ai)
37
+ 2. Navigate to your dashboard
38
+ 3. Generate an API key
39
+
40
+ ### Set Your API Key
41
+
42
+ #### Option 1: Environment Variable (Recommended)
43
+
44
+ ```bash
45
+ export OMTX_API_KEY="your-api-key-here"
46
+ ```
47
+
48
+ #### Option 2: Pass to Client
49
+
50
+ ```python
51
+ from omtx import Client
52
+
53
+ client = Client(api_key="your-api-key-here")
54
+ ```
55
+
56
+ ## Examples
57
+
58
+ ### Generate Diligence Report
59
+
60
+ ```python
61
+ from omtx import Client
62
+
63
+ client = Client()
64
+
65
+ # Generate report for a molecular target
66
+ result = client.generate_diligence("KRAS")
67
+
68
+ # Access the summary
69
+ print(result.summary)
70
+
71
+ # Access full report data
72
+ print(result.report_data)
73
+ ```
74
+
75
+ ### Deep Research
76
+
77
+ ```python
78
+ from omtx import Client
79
+
80
+ client = Client()
81
+
82
+ # Perform deep research on a scientific query
83
+ research = client.deep_research(
84
+ "CAR-T therapy mechanisms and recent advances",
85
+ max_iterations=5 # Optional: more iterations = deeper research
86
+ )
87
+
88
+ # View the final report
89
+ print(research.final_report)
90
+
91
+ # Access individual findings
92
+ for finding in research.findings:
93
+ print(f"- {finding['claim']}")
94
+
95
+ # Check execution time
96
+ print(f"Research completed in {research.execution_time:.1f} seconds")
97
+ ```
98
+
99
+ ### Error Handling
100
+
101
+ ```python
102
+ from omtx import Client, OMTXError, InsufficientCreditsError
103
+
104
+ client = Client()
105
+
106
+ try:
107
+ result = client.generate_diligence("BRAF")
108
+ except InsufficientCreditsError as e:
109
+ print(f"Not enough credits. Please add more credits to your account.")
110
+ except OMTXError as e:
111
+ print(f"An error occurred: {e}")
112
+ ```
113
+
114
+ ### Context Manager
115
+
116
+ ```python
117
+ from omtx import Client
118
+
119
+ # Automatically cleans up resources
120
+ with Client() as client:
121
+ result = client.generate_diligence("TP53")
122
+ print(result.summary)
123
+ ```
124
+
125
+ ## Available Methods
126
+
127
+ - `generate_diligence(target)` - Generate a comprehensive diligence report for a molecular target
128
+ - `deep_research(query, max_iterations=3)` - Perform iterative deep research on a scientific query
129
+ - `credits()` - Check available credits
130
+
131
+ ## Features
132
+
133
+ - **Simple API** - Just a few methods to remember
134
+ - **Automatic Retries** - Handles transient network errors automatically
135
+ - **Idempotency** - Safe to retry requests without double charges
136
+ - **Type Hints** - Full IDE autocomplete support
137
+ - **Error Handling** - Clear, actionable error messages
138
+
139
+ ## Requirements
140
+
141
+ - Python 3.8 or higher
142
+ - An OMTX API key
143
+
144
+ ## Support
145
+
146
+ - Email: support@omtx.ai
147
+ - Documentation: https://docs.omtx.ai
148
+ - Issues: https://github.com/omtx/python-sdk/issues
149
+
150
+ ## License
151
+
152
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,18 @@
1
+ """OMTX Python SDK - Clients for OM Gateway V2.
2
+
3
+ Includes:
4
+ - OMTXClient: Simple, explicit client with idempotency and typed methods
5
+ - Client: Dynamic endpoint registry alternative (advanced)
6
+ """
7
+
8
+ from .client import OMTXClient, Client
9
+ from .exceptions import OMTXError, InsufficientCreditsError, AuthenticationError
10
+
11
+ __version__ = "0.1.0"
12
+ __all__ = [
13
+ "OMTXClient",
14
+ "Client",
15
+ "OMTXError",
16
+ "InsufficientCreditsError",
17
+ "AuthenticationError",
18
+ ]
@@ -0,0 +1 @@
1
+ # Internal implementation details - not part of public API
@@ -0,0 +1,91 @@
1
+ """Internal HTTP client with automatic retry and idempotency"""
2
+ import os
3
+ import time
4
+ import uuid
5
+ from typing import Dict, Any, Optional
6
+ import httpx
7
+ from ..exceptions import OMTXError, AuthenticationError, InsufficientCreditsError, APIError
8
+
9
+
10
+ class HTTPClient:
11
+ """Handles all HTTP communication with the OM API Gateway"""
12
+
13
+ def __init__(self, api_key: str = None, base_url: str = None):
14
+ self.api_key = api_key or os.environ.get("OMTX_API_KEY")
15
+ if not self.api_key:
16
+ raise AuthenticationError(
17
+ "API key required. Pass api_key to Client() or set OMTX_API_KEY environment variable"
18
+ )
19
+
20
+ self.base_url = base_url or os.environ.get("OMTX_API_URL", "https://api.omtx.ai")
21
+ self.client = httpx.Client(timeout=60.0)
22
+
23
+ def request(self, method: str, path: str, json: Dict[str, Any] = None) -> Dict[str, Any]:
24
+ """Make HTTP request with automatic retry and idempotency"""
25
+ # Generate idempotency key for non-GET requests
26
+ headers = {"X-API-Key": self.api_key}
27
+ if method != "GET":
28
+ headers["Idempotency-Key"] = str(uuid.uuid4())
29
+
30
+ url = f"{self.base_url}{path}"
31
+
32
+ # Retry logic with exponential backoff
33
+ last_error = None
34
+ for attempt in range(3):
35
+ try:
36
+ response = self.client.request(
37
+ method=method,
38
+ url=url,
39
+ headers=headers,
40
+ json=json
41
+ )
42
+
43
+ # Handle successful responses
44
+ if response.status_code == 200:
45
+ return response.json()
46
+
47
+ # Handle specific error codes
48
+ if response.status_code == 401:
49
+ raise AuthenticationError("Invalid API key")
50
+ elif response.status_code == 402:
51
+ raise InsufficientCreditsError("Insufficient credits")
52
+ elif response.status_code == 404:
53
+ raise OMTXError(f"Endpoint not found: {path}")
54
+ elif response.status_code >= 500:
55
+ # Server error - retry
56
+ last_error = APIError(
57
+ f"Server error: {response.text}",
58
+ status_code=response.status_code
59
+ )
60
+ if attempt < 2: # Don't sleep on last attempt
61
+ time.sleep(2 ** attempt) # Exponential backoff
62
+ continue
63
+ else:
64
+ # Other client errors
65
+ try:
66
+ error_detail = response.json().get("detail", response.text)
67
+ except:
68
+ error_detail = response.text
69
+ raise APIError(error_detail, status_code=response.status_code)
70
+
71
+ except httpx.NetworkError as e:
72
+ # Network error - retry
73
+ last_error = OMTXError(f"Network error: {str(e)}")
74
+ if attempt < 2:
75
+ time.sleep(2 ** attempt)
76
+ continue
77
+
78
+ # All retries failed
79
+ raise last_error or OMTXError("Request failed after 3 attempts")
80
+
81
+ def get(self, path: str) -> Dict[str, Any]:
82
+ """GET request"""
83
+ return self.request("GET", path)
84
+
85
+ def post(self, path: str, json: Dict[str, Any]) -> Dict[str, Any]:
86
+ """POST request"""
87
+ return self.request("POST", path, json)
88
+
89
+ def close(self):
90
+ """Close the HTTP client"""
91
+ self.client.close()