seltz 0.0.1__tar.gz → 0.1.1__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.
- seltz-0.1.1/PKG-INFO +124 -0
- seltz-0.1.1/README.md +99 -0
- seltz-0.1.1/pyproject.toml +61 -0
- seltz-0.1.1/src/seltz/__init__.py +23 -0
- seltz-0.1.1/src/seltz/client.py +36 -0
- seltz-0.1.1/src/seltz/exceptions.py +53 -0
- seltz-0.1.1/src/seltz/seltz.py +48 -0
- seltz-0.1.1/src/seltz/services/__init__.py +18 -0
- seltz-0.1.1/src/seltz/services/search_service.py +62 -0
- seltz-0.1.1/src/seltz.egg-info/PKG-INFO +124 -0
- seltz-0.1.1/src/seltz.egg-info/SOURCES.txt +16 -0
- seltz-0.1.1/src/seltz.egg-info/requires.txt +2 -0
- seltz-0.1.1/src/seltz.egg-info/top_level.txt +2 -0
- seltz-0.1.1/src/seltz_public_api/proto/v1/seltz_pb2.py +44 -0
- seltz-0.1.1/src/seltz_public_api/proto/v1/seltz_pb2.pyi +43 -0
- seltz-0.1.1/src/seltz_public_api/proto/v1/seltz_pb2_grpc.py +77 -0
- seltz-0.0.1/PKG-INFO +0 -8
- seltz-0.0.1/README.md +0 -0
- seltz-0.0.1/seltz.egg-info/PKG-INFO +0 -8
- seltz-0.0.1/seltz.egg-info/SOURCES.txt +0 -6
- seltz-0.0.1/seltz.egg-info/top_level.txt +0 -1
- seltz-0.0.1/setup.py +0 -17
- {seltz-0.0.1 → seltz-0.1.1}/setup.cfg +0 -0
- {seltz-0.0.1 → seltz-0.1.1/src}/seltz.egg-info/dependency_links.txt +0 -0
seltz-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seltz
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Seltz Python SDK for AI-powered search
|
|
5
|
+
Author-email: Seltz <support@seltz.ai>
|
|
6
|
+
Project-URL: Homepage, https://seltz.ai
|
|
7
|
+
Project-URL: Documentation, https://docs.seltz.ai
|
|
8
|
+
Project-URL: Repository, https://github.com/seltz-ai/seltz-py
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/seltz-ai/seltz-py/issues
|
|
10
|
+
Keywords: search,ai,sdk,api
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: grpcio>=1.76.0
|
|
24
|
+
Requires-Dist: protobuf>=6.33.1
|
|
25
|
+
|
|
26
|
+
# Seltz Python SDK
|
|
27
|
+
|
|
28
|
+
The official Python SDK for the Seltz AI-powered search API.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install seltz
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from seltz import Seltz
|
|
40
|
+
|
|
41
|
+
# Initialize with API key
|
|
42
|
+
client = Seltz.create(api_key="your-api-key")
|
|
43
|
+
|
|
44
|
+
# Perform a search
|
|
45
|
+
response = client.search("your search query")
|
|
46
|
+
|
|
47
|
+
# Access results
|
|
48
|
+
for document in response.documents:
|
|
49
|
+
print(f"URL: {document.url}")
|
|
50
|
+
print(f"Content: {document.content}")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API Key
|
|
54
|
+
|
|
55
|
+
Set your API key using one of these methods:
|
|
56
|
+
|
|
57
|
+
1. **Environment variable** (recommended):
|
|
58
|
+
```bash
|
|
59
|
+
export SELTZ_API_KEY="your-api-key"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. **Direct parameter**:
|
|
63
|
+
```python
|
|
64
|
+
client = Seltz.create(api_key="your-api-key")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### `Seltz.create(api_key=None, endpoint="api.seltz.ai", insecure=False)`
|
|
70
|
+
|
|
71
|
+
Creates a new Seltz client instance.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `api_key` (str, optional): API key for authentication. Defaults to `SELTZ_API_KEY` environment variable.
|
|
75
|
+
- `endpoint` (str): API endpoint. Defaults to "api.seltz.ai".
|
|
76
|
+
- `insecure` (bool): Use insecure connection. Defaults to False.
|
|
77
|
+
|
|
78
|
+
**Returns:** `Seltz` instance
|
|
79
|
+
|
|
80
|
+
### `client.search(text, max_documents=10)`
|
|
81
|
+
|
|
82
|
+
Performs a search query.
|
|
83
|
+
|
|
84
|
+
**Parameters:**
|
|
85
|
+
- `text` (str): The search query text.
|
|
86
|
+
- `max_documents` (int): Maximum number of documents to return. Defaults to 10.
|
|
87
|
+
|
|
88
|
+
**Returns:** `SearchResponse` with a `documents` field containing search results.
|
|
89
|
+
|
|
90
|
+
## Error Handling
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from seltz import (
|
|
94
|
+
Seltz,
|
|
95
|
+
SeltzConfigurationError,
|
|
96
|
+
SeltzAuthenticationError,
|
|
97
|
+
SeltzConnectionError,
|
|
98
|
+
SeltzAPIError,
|
|
99
|
+
SeltzTimeoutError,
|
|
100
|
+
SeltzRateLimitError,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
client = Seltz.create(api_key="your-api-key")
|
|
105
|
+
response = client.search("query")
|
|
106
|
+
except SeltzConfigurationError as e:
|
|
107
|
+
print(f"Configuration error: {e}")
|
|
108
|
+
except SeltzAuthenticationError as e:
|
|
109
|
+
print(f"Authentication error: {e}")
|
|
110
|
+
except SeltzConnectionError as e:
|
|
111
|
+
print(f"Connection error: {e}")
|
|
112
|
+
except SeltzTimeoutError as e:
|
|
113
|
+
print(f"Timeout error: {e}")
|
|
114
|
+
except SeltzRateLimitError as e:
|
|
115
|
+
print(f"Rate limit error: {e}")
|
|
116
|
+
except SeltzAPIError as e:
|
|
117
|
+
print(f"API error: {e}")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Requirements
|
|
121
|
+
|
|
122
|
+
- Python 3.8+
|
|
123
|
+
- grpcio >= 1.76.0
|
|
124
|
+
- protobuf >= 6.33.1
|
seltz-0.1.1/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Seltz Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the Seltz AI-powered search API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install seltz
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from seltz import Seltz
|
|
15
|
+
|
|
16
|
+
# Initialize with API key
|
|
17
|
+
client = Seltz.create(api_key="your-api-key")
|
|
18
|
+
|
|
19
|
+
# Perform a search
|
|
20
|
+
response = client.search("your search query")
|
|
21
|
+
|
|
22
|
+
# Access results
|
|
23
|
+
for document in response.documents:
|
|
24
|
+
print(f"URL: {document.url}")
|
|
25
|
+
print(f"Content: {document.content}")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API Key
|
|
29
|
+
|
|
30
|
+
Set your API key using one of these methods:
|
|
31
|
+
|
|
32
|
+
1. **Environment variable** (recommended):
|
|
33
|
+
```bash
|
|
34
|
+
export SELTZ_API_KEY="your-api-key"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
2. **Direct parameter**:
|
|
38
|
+
```python
|
|
39
|
+
client = Seltz.create(api_key="your-api-key")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API Reference
|
|
43
|
+
|
|
44
|
+
### `Seltz.create(api_key=None, endpoint="api.seltz.ai", insecure=False)`
|
|
45
|
+
|
|
46
|
+
Creates a new Seltz client instance.
|
|
47
|
+
|
|
48
|
+
**Parameters:**
|
|
49
|
+
- `api_key` (str, optional): API key for authentication. Defaults to `SELTZ_API_KEY` environment variable.
|
|
50
|
+
- `endpoint` (str): API endpoint. Defaults to "api.seltz.ai".
|
|
51
|
+
- `insecure` (bool): Use insecure connection. Defaults to False.
|
|
52
|
+
|
|
53
|
+
**Returns:** `Seltz` instance
|
|
54
|
+
|
|
55
|
+
### `client.search(text, max_documents=10)`
|
|
56
|
+
|
|
57
|
+
Performs a search query.
|
|
58
|
+
|
|
59
|
+
**Parameters:**
|
|
60
|
+
- `text` (str): The search query text.
|
|
61
|
+
- `max_documents` (int): Maximum number of documents to return. Defaults to 10.
|
|
62
|
+
|
|
63
|
+
**Returns:** `SearchResponse` with a `documents` field containing search results.
|
|
64
|
+
|
|
65
|
+
## Error Handling
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from seltz import (
|
|
69
|
+
Seltz,
|
|
70
|
+
SeltzConfigurationError,
|
|
71
|
+
SeltzAuthenticationError,
|
|
72
|
+
SeltzConnectionError,
|
|
73
|
+
SeltzAPIError,
|
|
74
|
+
SeltzTimeoutError,
|
|
75
|
+
SeltzRateLimitError,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
client = Seltz.create(api_key="your-api-key")
|
|
80
|
+
response = client.search("query")
|
|
81
|
+
except SeltzConfigurationError as e:
|
|
82
|
+
print(f"Configuration error: {e}")
|
|
83
|
+
except SeltzAuthenticationError as e:
|
|
84
|
+
print(f"Authentication error: {e}")
|
|
85
|
+
except SeltzConnectionError as e:
|
|
86
|
+
print(f"Connection error: {e}")
|
|
87
|
+
except SeltzTimeoutError as e:
|
|
88
|
+
print(f"Timeout error: {e}")
|
|
89
|
+
except SeltzRateLimitError as e:
|
|
90
|
+
print(f"Rate limit error: {e}")
|
|
91
|
+
except SeltzAPIError as e:
|
|
92
|
+
print(f"API error: {e}")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Requirements
|
|
96
|
+
|
|
97
|
+
- Python 3.8+
|
|
98
|
+
- grpcio >= 1.76.0
|
|
99
|
+
- protobuf >= 6.33.1
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "seltz"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Seltz Python SDK for AI-powered search"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Seltz", email = "support@seltz.ai"}
|
|
13
|
+
]
|
|
14
|
+
keywords = ["search", "ai", "sdk", "api"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"Topic :: Internet :: WWW/HTTP :: Indexing/Search"
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"grpcio>=1.76.0",
|
|
29
|
+
"protobuf>=6.33.1",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://seltz.ai"
|
|
34
|
+
Documentation = "https://docs.seltz.ai"
|
|
35
|
+
Repository = "https://github.com/seltz-ai/seltz-py"
|
|
36
|
+
"Bug Tracker" = "https://github.com/seltz-ai/seltz-py/issues"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
include = ["seltz", "seltz.*", "seltz_public_api", "seltz_public_api.*"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-dir]
|
|
43
|
+
"" = "src"
|
|
44
|
+
"seltz_public_api" = "src/seltz_public_api"
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"build>=1.3.0",
|
|
49
|
+
"ruff>=0.14.7",
|
|
50
|
+
"twine>=6.2.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint.isort]
|
|
54
|
+
force-single-line = false
|
|
55
|
+
split-on-trailing-comma = true
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
exclude = [
|
|
60
|
+
"src/seltz/seltz_public_api/"
|
|
61
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Seltz Python SDK for interacting with the Seltz API."""
|
|
2
|
+
|
|
3
|
+
from .exceptions import (
|
|
4
|
+
SeltzAPIError,
|
|
5
|
+
SeltzAuthenticationError,
|
|
6
|
+
SeltzConfigurationError,
|
|
7
|
+
SeltzConnectionError,
|
|
8
|
+
SeltzError,
|
|
9
|
+
SeltzRateLimitError,
|
|
10
|
+
SeltzTimeoutError,
|
|
11
|
+
)
|
|
12
|
+
from .seltz import Seltz
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Seltz",
|
|
16
|
+
"SeltzError",
|
|
17
|
+
"SeltzConfigurationError",
|
|
18
|
+
"SeltzAuthenticationError",
|
|
19
|
+
"SeltzConnectionError",
|
|
20
|
+
"SeltzAPIError",
|
|
21
|
+
"SeltzTimeoutError",
|
|
22
|
+
"SeltzRateLimitError",
|
|
23
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import grpc
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SeltzClient:
|
|
5
|
+
"""Low-level gRPC client for Seltz API."""
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self, endpoint: str, api_key: str | None = None, insecure: bool = False
|
|
9
|
+
):
|
|
10
|
+
"""Initialize the Seltz gRPC client.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
endpoint: The gRPC endpoint to connect to
|
|
14
|
+
api_key: API key for authentication
|
|
15
|
+
insecure: Whether to use insecure connection (default: False)
|
|
16
|
+
"""
|
|
17
|
+
options = [
|
|
18
|
+
("grpc.keepalive_time_ms", 30000),
|
|
19
|
+
("grpc.keepalive_timeout_ms", 5000),
|
|
20
|
+
("grpc.keepalive_permit_without_calls", True),
|
|
21
|
+
("grpc.http2.max_pings_without_data", 0),
|
|
22
|
+
("grpc.http2.min_time_between_pings_ms", 10000),
|
|
23
|
+
("grpc.http2.min_ping_interval_without_data_ms", 300000),
|
|
24
|
+
("grpc.http2.write_buffer_size", 0),
|
|
25
|
+
("grpc.http2.max_frame_size", 4194304),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
if insecure:
|
|
29
|
+
channel = grpc.insecure_channel(endpoint, options=options)
|
|
30
|
+
else:
|
|
31
|
+
channel = grpc.secure_channel(
|
|
32
|
+
endpoint, grpc.ssl_channel_credentials(), options=options
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
self.channel = channel
|
|
36
|
+
self.api_key = api_key
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Custom exceptions for the Seltz SDK."""
|
|
2
|
+
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SeltzError(Exception):
|
|
7
|
+
"""Base exception for all Seltz SDK errors."""
|
|
8
|
+
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SeltzConfigurationError(SeltzError):
|
|
13
|
+
"""Raised when there's a configuration issue."""
|
|
14
|
+
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SeltzAuthenticationError(SeltzError):
|
|
19
|
+
"""Raised when authentication fails."""
|
|
20
|
+
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SeltzConnectionError(SeltzError):
|
|
25
|
+
"""Raised when connection to the API fails."""
|
|
26
|
+
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SeltzAPIError(SeltzError):
|
|
31
|
+
"""Raised when the API returns an error."""
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
message: str,
|
|
36
|
+
grpc_code: grpc.StatusCode | None = None,
|
|
37
|
+
grpc_details: str | None = None,
|
|
38
|
+
):
|
|
39
|
+
super().__init__(message)
|
|
40
|
+
self.grpc_code = grpc_code
|
|
41
|
+
self.grpc_details = grpc_details
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class SeltzTimeoutError(SeltzError):
|
|
45
|
+
"""Raised when a request times out."""
|
|
46
|
+
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class SeltzRateLimitError(SeltzError):
|
|
51
|
+
"""Raised when rate limit is exceeded."""
|
|
52
|
+
|
|
53
|
+
pass
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from .client import SeltzClient
|
|
4
|
+
from .exceptions import SeltzConfigurationError
|
|
5
|
+
from .services import SearchResponse
|
|
6
|
+
from .services.search_service import SearchService
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Seltz:
|
|
10
|
+
"""Main Seltz SDK client for interacting with the Seltz API."""
|
|
11
|
+
|
|
12
|
+
_ENDPOINT: str = "api.seltz.ai"
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
api_key: str | None = os.environ.get("SELTZ_API_KEY"),
|
|
17
|
+
endpoint: str = _ENDPOINT,
|
|
18
|
+
insecure: bool = False,
|
|
19
|
+
):
|
|
20
|
+
"""Initialize the Seltz client.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
api_key: API key for authentication. If None, will try to read from SELTZ_API_KEY environment variable
|
|
24
|
+
endpoint: The API endpoint to connect to (default: api.seltz.ai)
|
|
25
|
+
insecure: Whether to use insecure connection (default: False)
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
Seltz: A new Seltz client instance
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
SeltzConfigurationError: If no API key is provided
|
|
32
|
+
"""
|
|
33
|
+
if api_key is None:
|
|
34
|
+
raise SeltzConfigurationError("No API key provided")
|
|
35
|
+
self._client = SeltzClient(endpoint=endpoint, api_key=api_key, insecure=insecure)
|
|
36
|
+
self._search = SearchService(self._client.channel, self._client.api_key)
|
|
37
|
+
|
|
38
|
+
def search(self, text: str, max_documents: int = 10) -> SearchResponse:
|
|
39
|
+
"""Perform a search query.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
text: The search query text
|
|
43
|
+
max_documents: Maximum number of documents to return (default: 10)
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
SearchResponse: The search results
|
|
47
|
+
"""
|
|
48
|
+
return self._search.search(text, max_documents=max_documents)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Service layer with centralized protobuf imports for API version management."""
|
|
2
|
+
|
|
3
|
+
# Centralized protobuf imports - update these when API version changes
|
|
4
|
+
from seltz_public_api.proto.v1.seltz_pb2 import (
|
|
5
|
+
Document,
|
|
6
|
+
Includes,
|
|
7
|
+
SearchRequest,
|
|
8
|
+
SearchResponse,
|
|
9
|
+
)
|
|
10
|
+
from seltz_public_api.proto.v1.seltz_pb2_grpc import SeltzServiceStub
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"SeltzServiceStub",
|
|
14
|
+
"SearchRequest",
|
|
15
|
+
"SearchResponse",
|
|
16
|
+
"Includes",
|
|
17
|
+
"Document",
|
|
18
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import grpc
|
|
2
|
+
|
|
3
|
+
from ..exceptions import (
|
|
4
|
+
SeltzAPIError,
|
|
5
|
+
SeltzAuthenticationError,
|
|
6
|
+
SeltzConnectionError,
|
|
7
|
+
SeltzRateLimitError,
|
|
8
|
+
SeltzTimeoutError,
|
|
9
|
+
)
|
|
10
|
+
from . import Includes, SearchRequest, SearchResponse, SeltzServiceStub
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchService:
|
|
14
|
+
"""Service for performing search operations via gRPC."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, channel: grpc.Channel, api_key: str | None):
|
|
17
|
+
"""Initialize the search service.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
channel: gRPC channel for communication
|
|
21
|
+
api_key: API key for authentication
|
|
22
|
+
"""
|
|
23
|
+
self._stub = SeltzServiceStub(channel)
|
|
24
|
+
self._api_key = api_key
|
|
25
|
+
|
|
26
|
+
def search(self, query: str, max_documents: int = 10) -> SearchResponse:
|
|
27
|
+
"""Perform a search query.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
query: The search query string
|
|
31
|
+
max_documents: Maximum number of documents to return (default: 10)
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
SearchResponse containing the search results
|
|
35
|
+
|
|
36
|
+
Raises:
|
|
37
|
+
grpc.RpcError: If the gRPC call fails
|
|
38
|
+
"""
|
|
39
|
+
includes = Includes(max_documents=max_documents)
|
|
40
|
+
req = SearchRequest(query=query, includes=includes)
|
|
41
|
+
|
|
42
|
+
metadata = []
|
|
43
|
+
if self._api_key:
|
|
44
|
+
metadata.append(("authorization", f"Bearer {self._api_key}"))
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
return self._stub.Search(req, metadata=metadata, timeout=30)
|
|
48
|
+
except grpc.RpcError as e:
|
|
49
|
+
if e.code() == grpc.StatusCode.UNAUTHENTICATED:
|
|
50
|
+
raise SeltzAuthenticationError(
|
|
51
|
+
f"Authentication failed: {e.details()}"
|
|
52
|
+
) from e
|
|
53
|
+
elif e.code() == grpc.StatusCode.UNAVAILABLE:
|
|
54
|
+
raise SeltzConnectionError(f"Connection failed: {e.details()}") from e
|
|
55
|
+
elif e.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
|
|
56
|
+
raise SeltzTimeoutError(f"Request timed out: {e.details()}") from e
|
|
57
|
+
elif e.code() == grpc.StatusCode.RESOURCE_EXHAUSTED:
|
|
58
|
+
raise SeltzRateLimitError(f"Rate limit exceeded: {e.details()}") from e
|
|
59
|
+
else:
|
|
60
|
+
raise SeltzAPIError(
|
|
61
|
+
f"API error: {e.details()}", e.code(), e.details()
|
|
62
|
+
) from e
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seltz
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Seltz Python SDK for AI-powered search
|
|
5
|
+
Author-email: Seltz <support@seltz.ai>
|
|
6
|
+
Project-URL: Homepage, https://seltz.ai
|
|
7
|
+
Project-URL: Documentation, https://docs.seltz.ai
|
|
8
|
+
Project-URL: Repository, https://github.com/seltz-ai/seltz-py
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/seltz-ai/seltz-py/issues
|
|
10
|
+
Keywords: search,ai,sdk,api
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: grpcio>=1.76.0
|
|
24
|
+
Requires-Dist: protobuf>=6.33.1
|
|
25
|
+
|
|
26
|
+
# Seltz Python SDK
|
|
27
|
+
|
|
28
|
+
The official Python SDK for the Seltz AI-powered search API.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install seltz
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from seltz import Seltz
|
|
40
|
+
|
|
41
|
+
# Initialize with API key
|
|
42
|
+
client = Seltz.create(api_key="your-api-key")
|
|
43
|
+
|
|
44
|
+
# Perform a search
|
|
45
|
+
response = client.search("your search query")
|
|
46
|
+
|
|
47
|
+
# Access results
|
|
48
|
+
for document in response.documents:
|
|
49
|
+
print(f"URL: {document.url}")
|
|
50
|
+
print(f"Content: {document.content}")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API Key
|
|
54
|
+
|
|
55
|
+
Set your API key using one of these methods:
|
|
56
|
+
|
|
57
|
+
1. **Environment variable** (recommended):
|
|
58
|
+
```bash
|
|
59
|
+
export SELTZ_API_KEY="your-api-key"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. **Direct parameter**:
|
|
63
|
+
```python
|
|
64
|
+
client = Seltz.create(api_key="your-api-key")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### `Seltz.create(api_key=None, endpoint="api.seltz.ai", insecure=False)`
|
|
70
|
+
|
|
71
|
+
Creates a new Seltz client instance.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `api_key` (str, optional): API key for authentication. Defaults to `SELTZ_API_KEY` environment variable.
|
|
75
|
+
- `endpoint` (str): API endpoint. Defaults to "api.seltz.ai".
|
|
76
|
+
- `insecure` (bool): Use insecure connection. Defaults to False.
|
|
77
|
+
|
|
78
|
+
**Returns:** `Seltz` instance
|
|
79
|
+
|
|
80
|
+
### `client.search(text, max_documents=10)`
|
|
81
|
+
|
|
82
|
+
Performs a search query.
|
|
83
|
+
|
|
84
|
+
**Parameters:**
|
|
85
|
+
- `text` (str): The search query text.
|
|
86
|
+
- `max_documents` (int): Maximum number of documents to return. Defaults to 10.
|
|
87
|
+
|
|
88
|
+
**Returns:** `SearchResponse` with a `documents` field containing search results.
|
|
89
|
+
|
|
90
|
+
## Error Handling
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from seltz import (
|
|
94
|
+
Seltz,
|
|
95
|
+
SeltzConfigurationError,
|
|
96
|
+
SeltzAuthenticationError,
|
|
97
|
+
SeltzConnectionError,
|
|
98
|
+
SeltzAPIError,
|
|
99
|
+
SeltzTimeoutError,
|
|
100
|
+
SeltzRateLimitError,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
client = Seltz.create(api_key="your-api-key")
|
|
105
|
+
response = client.search("query")
|
|
106
|
+
except SeltzConfigurationError as e:
|
|
107
|
+
print(f"Configuration error: {e}")
|
|
108
|
+
except SeltzAuthenticationError as e:
|
|
109
|
+
print(f"Authentication error: {e}")
|
|
110
|
+
except SeltzConnectionError as e:
|
|
111
|
+
print(f"Connection error: {e}")
|
|
112
|
+
except SeltzTimeoutError as e:
|
|
113
|
+
print(f"Timeout error: {e}")
|
|
114
|
+
except SeltzRateLimitError as e:
|
|
115
|
+
print(f"Rate limit error: {e}")
|
|
116
|
+
except SeltzAPIError as e:
|
|
117
|
+
print(f"API error: {e}")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Requirements
|
|
121
|
+
|
|
122
|
+
- Python 3.8+
|
|
123
|
+
- grpcio >= 1.76.0
|
|
124
|
+
- protobuf >= 6.33.1
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/seltz/__init__.py
|
|
4
|
+
src/seltz/client.py
|
|
5
|
+
src/seltz/exceptions.py
|
|
6
|
+
src/seltz/seltz.py
|
|
7
|
+
src/seltz.egg-info/PKG-INFO
|
|
8
|
+
src/seltz.egg-info/SOURCES.txt
|
|
9
|
+
src/seltz.egg-info/dependency_links.txt
|
|
10
|
+
src/seltz.egg-info/requires.txt
|
|
11
|
+
src/seltz.egg-info/top_level.txt
|
|
12
|
+
src/seltz/services/__init__.py
|
|
13
|
+
src/seltz/services/search_service.py
|
|
14
|
+
src/seltz_public_api/proto/v1/seltz_pb2.py
|
|
15
|
+
src/seltz_public_api/proto/v1/seltz_pb2.pyi
|
|
16
|
+
src/seltz_public_api/proto/v1/seltz_pb2_grpc.py
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: seltz_public_api/proto/v1/seltz.proto
|
|
5
|
+
# Protobuf Python Version: 6.33.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
6,
|
|
15
|
+
33,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'seltz_public_api/proto/v1/seltz.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%seltz_public_api/proto/v1/seltz.proto\x12\x19seltz_public_api.proto.v1\"F\n\x08Includes\x12(\n\rmax_documents\x18\x01 \x01(\rH\x00R\x0cmaxDocuments\x88\x01\x01\x42\x10\n\x0e_max_documents\"\xce\x01\n\rSearchRequest\x12\x14\n\x05query\x18\x01 \x01(\tR\x05query\x12\x44\n\x08includes\x18\x02 \x01(\x0b\x32#.seltz_public_api.proto.v1.IncludesH\x00R\x08includes\x88\x01\x01\x12\x1d\n\x07\x63ontext\x18\x03 \x01(\tH\x01R\x07\x63ontext\x88\x01\x01\x12\x1d\n\x07profile\x18\x04 \x01(\tH\x02R\x07profile\x88\x01\x01\x42\x0b\n\t_includesB\n\n\x08_contextB\n\n\x08_profile\"T\n\x08\x44ocument\x12\x15\n\x03url\x18\x01 \x01(\tH\x00R\x03url\x88\x01\x01\x12\x1d\n\x07\x63ontent\x18\x02 \x01(\tH\x01R\x07\x63ontent\x88\x01\x01\x42\x06\n\x04_urlB\n\n\x08_content\"S\n\x0eSearchResponse\x12\x41\n\tdocuments\x18\x01 \x03(\x0b\x32#.seltz_public_api.proto.v1.DocumentR\tdocuments2m\n\x0cSeltzService\x12]\n\x06Search\x12(.seltz_public_api.proto.v1.SearchRequest\x1a).seltz_public_api.proto.v1.SearchResponseb\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'seltz_public_api.proto.v1.seltz_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_INCLUDES']._serialized_start=68
|
|
35
|
+
_globals['_INCLUDES']._serialized_end=138
|
|
36
|
+
_globals['_SEARCHREQUEST']._serialized_start=141
|
|
37
|
+
_globals['_SEARCHREQUEST']._serialized_end=347
|
|
38
|
+
_globals['_DOCUMENT']._serialized_start=349
|
|
39
|
+
_globals['_DOCUMENT']._serialized_end=433
|
|
40
|
+
_globals['_SEARCHRESPONSE']._serialized_start=435
|
|
41
|
+
_globals['_SEARCHRESPONSE']._serialized_end=518
|
|
42
|
+
_globals['_SELTZSERVICE']._serialized_start=520
|
|
43
|
+
_globals['_SELTZSERVICE']._serialized_end=629
|
|
44
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from collections.abc import Iterable as _Iterable
|
|
2
|
+
from collections.abc import Mapping as _Mapping
|
|
3
|
+
from typing import ClassVar as _ClassVar
|
|
4
|
+
from typing import Optional as _Optional
|
|
5
|
+
from typing import Union as _Union
|
|
6
|
+
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import message as _message
|
|
9
|
+
from google.protobuf.internal import containers as _containers
|
|
10
|
+
|
|
11
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
|
12
|
+
|
|
13
|
+
class Includes(_message.Message):
|
|
14
|
+
__slots__ = ()
|
|
15
|
+
MAX_DOCUMENTS_FIELD_NUMBER: _ClassVar[int]
|
|
16
|
+
max_documents: int
|
|
17
|
+
def __init__(self, max_documents: _Optional[int] = ...) -> None: ...
|
|
18
|
+
|
|
19
|
+
class SearchRequest(_message.Message):
|
|
20
|
+
__slots__ = ()
|
|
21
|
+
QUERY_FIELD_NUMBER: _ClassVar[int]
|
|
22
|
+
INCLUDES_FIELD_NUMBER: _ClassVar[int]
|
|
23
|
+
CONTEXT_FIELD_NUMBER: _ClassVar[int]
|
|
24
|
+
PROFILE_FIELD_NUMBER: _ClassVar[int]
|
|
25
|
+
query: str
|
|
26
|
+
includes: Includes
|
|
27
|
+
context: str
|
|
28
|
+
profile: str
|
|
29
|
+
def __init__(self, query: _Optional[str] = ..., includes: _Optional[_Union[Includes, _Mapping]] = ..., context: _Optional[str] = ..., profile: _Optional[str] = ...) -> None: ...
|
|
30
|
+
|
|
31
|
+
class Document(_message.Message):
|
|
32
|
+
__slots__ = ()
|
|
33
|
+
URL_FIELD_NUMBER: _ClassVar[int]
|
|
34
|
+
CONTENT_FIELD_NUMBER: _ClassVar[int]
|
|
35
|
+
url: str
|
|
36
|
+
content: str
|
|
37
|
+
def __init__(self, url: _Optional[str] = ..., content: _Optional[str] = ...) -> None: ...
|
|
38
|
+
|
|
39
|
+
class SearchResponse(_message.Message):
|
|
40
|
+
__slots__ = ()
|
|
41
|
+
DOCUMENTS_FIELD_NUMBER: _ClassVar[int]
|
|
42
|
+
documents: _containers.RepeatedCompositeFieldContainer[Document]
|
|
43
|
+
def __init__(self, documents: _Optional[_Iterable[_Union[Document, _Mapping]]] = ...) -> None: ...
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
from seltz_public_api.proto.v1 import seltz_pb2 as seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SeltzServiceStub(object):
|
|
9
|
+
"""Missing associated documentation comment in .proto file."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, channel):
|
|
12
|
+
"""Constructor.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
channel: A grpc.Channel.
|
|
16
|
+
"""
|
|
17
|
+
self.Search = channel.unary_unary(
|
|
18
|
+
'/seltz_public_api.proto.v1.SeltzService/Search',
|
|
19
|
+
request_serializer=seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchRequest.SerializeToString,
|
|
20
|
+
response_deserializer=seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchResponse.FromString,
|
|
21
|
+
_registered_method=True)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SeltzServiceServicer(object):
|
|
25
|
+
"""Missing associated documentation comment in .proto file."""
|
|
26
|
+
|
|
27
|
+
def Search(self, request, context):
|
|
28
|
+
"""Missing associated documentation comment in .proto file."""
|
|
29
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
30
|
+
context.set_details('Method not implemented!')
|
|
31
|
+
raise NotImplementedError('Method not implemented!')
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def add_SeltzServiceServicer_to_server(servicer, server):
|
|
35
|
+
rpc_method_handlers = {
|
|
36
|
+
'Search': grpc.unary_unary_rpc_method_handler(
|
|
37
|
+
servicer.Search,
|
|
38
|
+
request_deserializer=seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchRequest.FromString,
|
|
39
|
+
response_serializer=seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchResponse.SerializeToString,
|
|
40
|
+
),
|
|
41
|
+
}
|
|
42
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
43
|
+
'seltz_public_api.proto.v1.SeltzService', rpc_method_handlers)
|
|
44
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
45
|
+
server.add_registered_method_handlers('seltz_public_api.proto.v1.SeltzService', rpc_method_handlers)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# This class is part of an EXPERIMENTAL API.
|
|
49
|
+
class SeltzService(object):
|
|
50
|
+
"""Missing associated documentation comment in .proto file."""
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def Search(request,
|
|
54
|
+
target,
|
|
55
|
+
options=(),
|
|
56
|
+
channel_credentials=None,
|
|
57
|
+
call_credentials=None,
|
|
58
|
+
insecure=False,
|
|
59
|
+
compression=None,
|
|
60
|
+
wait_for_ready=None,
|
|
61
|
+
timeout=None,
|
|
62
|
+
metadata=None):
|
|
63
|
+
return grpc.experimental.unary_unary(
|
|
64
|
+
request,
|
|
65
|
+
target,
|
|
66
|
+
'/seltz_public_api.proto.v1.SeltzService/Search',
|
|
67
|
+
seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchRequest.SerializeToString,
|
|
68
|
+
seltz__public__api_dot_proto_dot_v1_dot_seltz__pb2.SearchResponse.FromString,
|
|
69
|
+
options,
|
|
70
|
+
channel_credentials,
|
|
71
|
+
insecure,
|
|
72
|
+
call_credentials,
|
|
73
|
+
compression,
|
|
74
|
+
wait_for_ready,
|
|
75
|
+
timeout,
|
|
76
|
+
metadata,
|
|
77
|
+
_registered_method=True)
|
seltz-0.0.1/PKG-INFO
DELETED
seltz-0.0.1/README.md
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
seltz-0.0.1/setup.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import setuptools
|
|
2
|
-
|
|
3
|
-
setuptools.setup(
|
|
4
|
-
name="seltz",
|
|
5
|
-
version="0.0.1",
|
|
6
|
-
author="Elias Bassani",
|
|
7
|
-
author_email="elias.bssn@gmail.com",
|
|
8
|
-
description="",
|
|
9
|
-
long_description="",
|
|
10
|
-
long_description_content_type="text/markdown",
|
|
11
|
-
url="",
|
|
12
|
-
packages=setuptools.find_packages(),
|
|
13
|
-
install_requires=[],
|
|
14
|
-
classifiers=[],
|
|
15
|
-
keywords=[],
|
|
16
|
-
python_requires=">=3.9",
|
|
17
|
-
)
|
|
File without changes
|
|
File without changes
|