Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
# Text2Everything SDK Test Configuration
T2E_BASE_URL=http://localhost:8000
T2E_API_KEY=
T2E_ACCESS_TOKEN=
T2E_WORKSPACE_NAME=

# Snowflake Connector Settings (for SDK tests)
EXECUTIONS_CONNECTOR_ID=

# Snowflake Connector Settings (for SDK tests using username/password authentication)
SNOWFLAKE_HOST=
SNOWFLAKE_USERNAME=
SNOWFLAKE_PASSWORD=
SNOWFLAKE_DATABASE=
SNOWFLAKE_WAREHOUSE=
SNOWFLAKE_ROLE=

## Snowflake Connector Settings (for SDK tests using key pair authentication)
SNOWFLAKE_HOST=
SNOWFLAKE_USERNAME=
SNOWFLAKE_DATABASE=

# One of:
SNOWFLAKE_PASSWORD= # Replace with your password
# SNOWFLAKE_PASSWORD_SECRET_ID=workspace/secrets/snowflake-password

# Or
# One of:
SNOWFLAKE_PRIVATE_KEY= #(PEM content; SDK will send as config.private_key)
SNOWFLAKE_PRIVATE_KEY_SECRET_ID= #(maps to config.private_key_secret_id)
SNOWFLAKE_PRIVATE_KEY_SECRET_NAME= #(maps to config.private_key_secret_name)
# Optional:
SNOWFLAKE_PRIVATE_KEY_PASSPHRASE=
SNOWFLAKE_PRIVATE_KEY_PASSPHRASE_SECRET_ID=
SNOWFLAKE_PRIVATE_KEY_PASSPHRASE_SECRET_NAME=

SNOWFLAKE_WAREHOUSE=
SNOWFLAKE_ROLE=
SNOWFLAKE_SCHEMA=


# Note: Replace 'your-api-key-here' with an actual API key
# You can get an API key from the H2OGPTE application
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
.env
.env.upload

*.egg-info
__pycache__
.venv
managers/
jsons_generados_20250828/
site/
JSON - tests/

documentation/tmp/
documentation/node_modules/

h2o_jsons/
izzi_jsons/
9 changes: 6 additions & 3 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ from text2everything_sdk import Text2EverythingClient
# Initialize client
client = Text2EverythingClient(
base_url="https://your-api-endpoint.com",
api_key="your-api-key"
access_token="your-access-token",
workspace_name="workspaces/my-workspace"
)

# Create a project
Expand Down Expand Up @@ -122,7 +123,8 @@ Create a `.env` file in your project root:
```bash
# .env file
T2E_BASE_URL=https://your-api-endpoint.com
T2E_API_KEY=your-api-key
T2E_ACCESS_TOKEN=your-access-token
T2E_WORKSPACE_NAME=workspaces/my-workspace
```

The SDK will automatically load these variables when running tests.
Expand All @@ -133,7 +135,8 @@ Alternatively, set environment variables:

```bash
export T2E_BASE_URL="https://your-api-endpoint.com"
export T2E_API_KEY="your-api-key"
export T2E_ACCESS_TOKEN="your-access-token"
export T2E_WORKSPACE_NAME="workspaces/my-workspace"
```

## Development Setup
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ from text2everything_sdk import Text2EverythingClient
# Initialize the client
client = Text2EverythingClient(
base_url="https://your-api-endpoint.com",
api_key="your-api-key"
access_token="your-access-token",
workspace_name="workspaces/my-workspace"
)

# Create a project
Expand Down Expand Up @@ -283,7 +284,8 @@ You can configure the SDK using environment variables:

```bash
export TEXT2EVERYTHING_BASE_URL="https://your-api-endpoint.com"
export H2OGPTE_API_KEY="your-h2ogpte-api-key"
export T2E_ACCESS_TOKEN="your-oidc-access-token"
export T2E_WORKSPACE_NAME="workspaces/my-workspace"
```

```python
Expand All @@ -292,7 +294,8 @@ from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(
base_url=os.getenv("TEXT2EVERYTHING_BASE_URL"),
api_key=os.getenv("H2OGPTE_API_KEY")
access_token=os.getenv("T2E_ACCESS_TOKEN"),
workspace_name=os.getenv("T2E_WORKSPACE_NAME")
)
```

Expand All @@ -303,7 +306,8 @@ For local development, create a `.env` file in your project root:
```bash
# .env file
T2E_BASE_URL=https://your-api-endpoint.com
T2E_API_KEY=your-h2ogpte-api-key
T2E_ACCESS_TOKEN=your-oidc-access-token
T2E_WORKSPACE_NAME=workspaces/my-workspace
```

The SDK will automatically load these variables when running tests:
Expand All @@ -321,7 +325,8 @@ client = Text2EverythingClient()
```python
client = Text2EverythingClient(
base_url="https://your-api-endpoint.com",
api_key="your-h2ogpte-api-key",
access_token="your-oidc-access-token",
workspace_name="workspaces/my-workspace",
timeout=60, # Request timeout in seconds
max_retries=5, # Maximum retry attempts
retry_delay=2.0 # Initial retry delay in seconds
Expand All @@ -333,7 +338,7 @@ client = Text2EverythingClient(
Use the client as a context manager for proper resource cleanup:

```python
with Text2EverythingClient(base_url="...", api_key="...") as client:
with Text2EverythingClient(base_url="...", access_token="...", workspace_name="workspaces/dev") as client:
projects = client.projects.list()
# Client will be automatically closed when exiting the context
```
Expand Down
17 changes: 14 additions & 3 deletions T2E Quick start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"load_dotenv()\n",
"\n",
"# Install the Text2Everything SDK (local installation)\n",
"!{sys.executable} -m pip install --upgrade ./text2everything_sdk-0.1.3-py3-none-any.whl"
"!{sys.executable} -m pip install --upgrade ./dist/text2everything_sdk-0.1.6-py3-none-any.whl"
]
},
{
Expand All @@ -55,11 +55,21 @@
" NotFoundError,\n",
" RateLimitError\n",
")\n",
"import h2o_authn\n",
"\n",
"print(\"✅ SDK imported successfully!\")\n",
"\n",
"PLATFORM_TOKEN = \"\" # Platform token from https://<your_cloud>.h2o.ai/auth/get-platform-token \n",
"token_provider = h2o_authn.TokenProvider(\n",
" refresh_token=PLATFORM_TOKEN,\n",
" client_id=\"hac-platform-public\", \n",
" token_endpoint_url=\"https://auth.<your_cloud>.h2o.ai/auth/realms/hac/protocol/openid-connect/token\" \n",
")\n",
"\n",
"# Configuration\n",
"API_KEY = \"\" # Replace with your H2O GPTE API key"
"\n",
"ACCESS_TOKEN = token_provider.token()\n",
"WORKSPACE_NAME = \"\" # Workspace name"
]
},
{
Expand All @@ -77,7 +87,8 @@
"source": [
"# Initialize the Text2Everything client\n",
"client = Text2EverythingClient(\n",
" api_key=API_KEY #h2ogpte api key\n",
" access_token=ACCESS_TOKEN,\n",
" workspace_name=WORKSPACE_NAME,\n",
")\n",
"\n",
"print(\"✅ Client initialized successfully!\")"
Expand Down
38 changes: 22 additions & 16 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class Text2EverythingClient:

Args:
base_url: The base URL of the Text2Everything API
api_key: Your API key for authentication
access_token: OIDC access token to send as Authorization Bearer
workspace_name: Optional workspace scope to include via X-Workspace-Name
timeout: Connection timeout in seconds (default: 30)
max_retries: Maximum number of retries for failed requests (default: 3)
retry_delay: Initial delay between retries in seconds (default: 1)
Expand All @@ -52,16 +53,17 @@ class Text2EverythingClient:
http2: Enable HTTP/2 support (default: False)

Example:
>>> # Standard usage
>>> # Standard usage (Bearer + optional workspace)
>>> client = Text2EverythingClient(
... base_url="https://api.text2everything.com",
... api_key="your-api-key"
... access_token="your-oidc-access-token",
... workspace_name="workspaces/my-workspace"
... )
>>>
>>> # High-concurrency configuration
>>> client = Text2EverythingClient(
... base_url="https://api.text2everything.com",
... api_key="your-api-key",
... access_token="your-oidc-access-token",
... read_timeout=300, # 5 minutes for long requests
... max_connections=100,
... max_keepalive_connections=20
Expand All @@ -72,7 +74,8 @@ class Text2EverythingClient:

def __init__(
self,
api_key: str,
access_token: str,
workspace_name: Optional[str] = None,
base_url: str = "http://text2everything.text2everything.svc.cluster.local:8000",
timeout: int = 30,
max_retries: int = 3,
Expand All @@ -87,11 +90,12 @@ def __init__(
):
if not base_url:
raise InvalidConfigurationError("base_url is required")
if not api_key:
raise InvalidConfigurationError("api_key is required")
if not access_token:
raise InvalidConfigurationError("access_token is required")

self.base_url = base_url.rstrip('/')
self.api_key = api_key
self.access_token = access_token
self.workspace_name = workspace_name
self.timeout = timeout
self.max_retries = max_retries
self.retry_delay = retry_delay
Expand Down Expand Up @@ -133,11 +137,14 @@ def __init__(

def _get_default_headers(self) -> Dict[str, str]:
"""Get default headers for API requests."""
return {
"X-API-Key": self.api_key,
headers: Dict[str, str] = {
"Content-Type": "application/json",
"User-Agent": "text2everything-sdk/1.0.0"
"User-Agent": "text2everything-sdk/1.0.0",
"Authorization": f"Bearer {self.access_token}",
}
if self.workspace_name:
headers["X-Workspace-Name"] = self.workspace_name
return headers

def _build_url(self, endpoint: str) -> str:
"""Build full URL from endpoint."""
Expand Down Expand Up @@ -319,11 +326,10 @@ def _make_multipart_request(
"""
url = self._build_url(endpoint)
# Start with default headers but remove Content-Type for multipart
request_headers = {
"X-API-Key": self.api_key,
"User-Agent": "text2everything-sdk/1.0.0"
# Don't set Content-Type for multipart, let httpx handle it
}
request_headers = self._get_default_headers().copy()
# Don't set Content-Type for multipart, let httpx set boundary
if "Content-Type" in request_headers:
request_headers.pop("Content-Type", None)

# Use list of tuples format which works with FastAPI
for attempt in range(self.max_retries + 1):
Expand Down
Binary file removed dist/text2everything_sdk-0.1.5-py3-none-any.whl
Binary file not shown.
Binary file removed dist/text2everything_sdk-0.1.5.tar.gz
Binary file not shown.
Binary file added dist/text2everything_sdk-0.1.6-py3-none-any.whl
Binary file not shown.
Binary file added dist/text2everything_sdk-0.1.6.tar.gz
Binary file not shown.
8 changes: 5 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(
base_url=os.getenv("TEXT2EVERYTHING_BASE_URL"),
api_key=os.getenv("TEXT2EVERYTHING_API_KEY"),
access_token=os.getenv("T2E_ACCESS_TOKEN"),
workspace_name=os.getenv("T2E_WORKSPACE_NAME"),
)
```

Advanced:
```python
client = Text2EverythingClient(
base_url="https://...",
api_key="...",
access_token="...",
workspace_name="workspaces/dev",
timeout=60,
max_retries=5,
retry_delay=2.0,
Expand All @@ -34,6 +36,6 @@ Context manager:
```python
from text2everything_sdk import Text2EverythingClient

with Text2EverythingClient(base_url="...", api_key="...") as client:
with Text2EverythingClient(base_url="...", access_token="...", workspace_name="workspaces/dev") as client:
projects = client.projects.list()
```
3 changes: 2 additions & 1 deletion docs/guides/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Optimize `Text2EverythingClient` for high-throughput and long-running requests.
```python
client = Text2EverythingClient(
base_url="https://...",
api_key="...",
access_token="...",
workspace_name="workspaces/dev",
read_timeout=300,
max_connections=100,
max_keepalive_connections=20,
Expand Down
11 changes: 9 additions & 2 deletions docs/guides/connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Create/list/get/update/delete:
```python
from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(base_url="https://...", api_key="...")
client = Text2EverythingClient(base_url="https://...", access_token="...", workspace_name="workspaces/dev")

# Create
conn = client.connectors.create(
Expand Down Expand Up @@ -37,6 +37,12 @@ Test connection (basic):
ok = client.connectors.test_connection(conn.id)
```

Test connection (detailed):
```python
details = client.connectors.test_connection_detailed(conn.id)
# {'ok': True, 'elapsed_ms': 123}
```

Filter by type:
```python
pg = client.connectors.list_by_type("postgres")
Expand All @@ -46,7 +52,7 @@ Snowflake connector example:
```python
from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(base_url="https://...", api_key="...")
client = Text2EverythingClient(base_url="https://...", access_token="...", workspace_name="workspaces/dev")

snowflake_conn = client.connectors.create(
name="Snowflake - Analytics",
Expand All @@ -64,4 +70,5 @@ snowflake_conn = client.connectors.create(

# Optional: test the connection
ok = client.connectors.test_connection(snowflake_conn.id)
details = client.connectors.test_connection_detailed(snowflake_conn.id)
```
2 changes: 1 addition & 1 deletion docs/guides/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ List/create/get/update/delete:
```python
from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(base_url="https://...", api_key="...")
client = Text2EverythingClient(base_url="https://...", access_token="...", workspace_name="workspaces/dev")
project = client.projects.create(name="Ctx Demo")

# Create
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ List/get/create/update/delete:
```python
from text2everything_sdk import Text2EverythingClient

client = Text2EverythingClient(base_url="https://...", api_key="...")
client = Text2EverythingClient(base_url="https://...", access_token="...", workspace_name="workspaces/dev")

# List
projects = client.projects.list()
Expand Down
Loading
Loading