snowleopard 0.1.1__tar.gz → 0.2.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.
- snowleopard-0.2.0/.claude/settings.local.json +17 -0
- {snowleopard-0.1.1 → snowleopard-0.2.0}/PKG-INFO +40 -29
- snowleopard-0.2.0/README.md +96 -0
- snowleopard-0.2.0/src/snowleopard/__init__.py +13 -0
- {snowleopard-0.1.1 → snowleopard-0.2.0}/src/snowleopard/async_client.py +6 -4
- {snowleopard-0.1.1 → snowleopard-0.2.0}/src/snowleopard/cli.py +19 -6
- {snowleopard-0.1.1 → snowleopard-0.2.0}/src/snowleopard/client.py +6 -4
- {snowleopard-0.1.1 → snowleopard-0.2.0}/src/snowleopard/client_base.py +43 -1
- {snowleopard-0.1.1 → snowleopard-0.2.0}/src/snowleopard/models.py +1 -0
- snowleopard-0.1.1/README.md +0 -85
- snowleopard-0.1.1/src/snowleopard/__init__.py +0 -13
- {snowleopard-0.1.1 → snowleopard-0.2.0}/.gitignore +0 -0
- {snowleopard-0.1.1 → snowleopard-0.2.0}/CONTRIBUTING.md +0 -0
- {snowleopard-0.1.1 → snowleopard-0.2.0}/LICENSE +0 -0
- {snowleopard-0.1.1 → snowleopard-0.2.0}/pyproject.toml +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(mkdir:*)",
|
|
5
|
+
"Bash(uv add:*)",
|
|
6
|
+
"Bash(uv run pytest:*)",
|
|
7
|
+
"WebFetch(domain:www.python-httpx.org)",
|
|
8
|
+
"Bash(python -c:*)",
|
|
9
|
+
"Bash(uv run python:*)",
|
|
10
|
+
"WebFetch(domain:github.com)",
|
|
11
|
+
"Bash(uv run snowy response --help:*)",
|
|
12
|
+
"Bash(uv run:*)"
|
|
13
|
+
],
|
|
14
|
+
"deny": [],
|
|
15
|
+
"ask": []
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: snowleopard
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: snowleopard.ai client library
|
|
5
5
|
Author-email: Snowy <hello@snowleopard.ai>
|
|
6
6
|
License: MIT License
|
|
@@ -34,7 +34,9 @@ Description-Content-Type: text/markdown
|
|
|
34
34
|
|
|
35
35
|
# Snow Leopard SDK for Python
|
|
36
36
|
|
|
37
|
-
Python client library for [Snow Leopard Playground](https://try.snowleopard.ai) APIs.
|
|
37
|
+
This repo contains the Python client library for [Snow Leopard Playground](https://try.snowleopard.ai) APIs.
|
|
38
|
+
|
|
39
|
+
See our [API documentation](https://docs.snowleopard.ai/#api-documentation) for more details.
|
|
38
40
|
|
|
39
41
|
## Installation
|
|
40
42
|
|
|
@@ -45,16 +47,13 @@ pip install snowleopard
|
|
|
45
47
|
## Quick Start
|
|
46
48
|
|
|
47
49
|
```python
|
|
48
|
-
from snowleopard import
|
|
50
|
+
from snowleopard import SnowLeopardClient
|
|
49
51
|
|
|
50
|
-
# Initialize the client (or
|
|
51
|
-
client =
|
|
52
|
+
# Initialize the client (or AsyncSnowLeopardClient)
|
|
53
|
+
client = SnowLeopardClient(api_key="your-api-key")
|
|
52
54
|
|
|
53
55
|
# Query your data in natural language
|
|
54
|
-
response = client.retrieve(
|
|
55
|
-
datafile_id="your-datafile-id",
|
|
56
|
-
user_query="How many users signed up last month?"
|
|
57
|
-
)
|
|
56
|
+
response = client.retrieve(user_query="How many users signed up last month?", datafile_id="your-datafile-id")
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
## Getting Started
|
|
@@ -69,7 +68,7 @@ response = client.retrieve(
|
|
|
69
68
|
Or pass it directly to the client:
|
|
70
69
|
|
|
71
70
|
```python
|
|
72
|
-
|
|
71
|
+
SnowLeopardClient(api_key="your-api-key")
|
|
73
72
|
```
|
|
74
73
|
|
|
75
74
|
## Usage
|
|
@@ -77,31 +76,31 @@ response = client.retrieve(
|
|
|
77
76
|
### Synchronous Client
|
|
78
77
|
|
|
79
78
|
```python
|
|
80
|
-
from snowleopard import
|
|
79
|
+
from snowleopard import SnowLeopardClient
|
|
81
80
|
|
|
82
|
-
with
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
with SnowLeopardClient() as client:
|
|
82
|
+
# Get data directly from a natural language query
|
|
83
|
+
response = client.retrieve(user_query="How many superheroes are there?")
|
|
84
|
+
print(response.data)
|
|
85
|
+
|
|
86
|
+
# Stream natural language summary of live data
|
|
87
|
+
for chunk in client.response(user_query="How many superheroes are there?"):
|
|
88
|
+
print(chunk)
|
|
90
89
|
```
|
|
91
90
|
|
|
92
91
|
### Async Client
|
|
93
92
|
|
|
94
93
|
```python
|
|
95
|
-
from snowleopard import
|
|
94
|
+
from snowleopard import AsyncSnowLeopardClient
|
|
96
95
|
|
|
97
|
-
async with
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
async with AsyncSnowLeopardClient() as client:
|
|
97
|
+
# Get complete results
|
|
98
|
+
response = await client.retrieve(user_query="How many superheroes are there?")
|
|
99
|
+
print(response.data)
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
# Get streaming results
|
|
102
|
+
async for chunk in client.response(user_query="How many superheroes are there?"):
|
|
103
|
+
print(chunk)
|
|
105
104
|
```
|
|
106
105
|
|
|
107
106
|
### CLI
|
|
@@ -110,10 +109,22 @@ The SDK includes a command-line interface:
|
|
|
110
109
|
|
|
111
110
|
```bash
|
|
112
111
|
pip install snowleopard
|
|
113
|
-
snowy retrieve <datafile-id> "How many records are there?"
|
|
114
|
-
snowy response <datafile-id> "Summarize the data"
|
|
112
|
+
snowy retrieve --datafile <datafile-id> "How many records are there?"
|
|
113
|
+
snowy response --datafile <datafile-id> "Summarize the data"
|
|
115
114
|
```
|
|
116
115
|
|
|
116
|
+
### On Premise Customers
|
|
117
|
+
|
|
118
|
+
For our customers who have a separate deployment per dataset, you should declare <url> explicitly when creating a
|
|
119
|
+
client and omit <datafile id> when querying.
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
```python
|
|
123
|
+
client = SnowLeopardClient(url="https://{your-vm-ip}:{port}", api_key="your-api-key")
|
|
124
|
+
response = client.retrieve(user_query="How many users signed up last month?")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
117
128
|
## Contributing
|
|
118
129
|
|
|
119
130
|
For SDK developer docs and how to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Snow Leopard SDK for Python
|
|
2
|
+
|
|
3
|
+
This repo contains the Python client library for [Snow Leopard Playground](https://try.snowleopard.ai) APIs.
|
|
4
|
+
|
|
5
|
+
See our [API documentation](https://docs.snowleopard.ai/#api-documentation) for more details.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install snowleopard
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from snowleopard import SnowLeopardClient
|
|
17
|
+
|
|
18
|
+
# Initialize the client (or AsyncSnowLeopardClient)
|
|
19
|
+
client = SnowLeopardClient(api_key="your-api-key")
|
|
20
|
+
|
|
21
|
+
# Query your data in natural language
|
|
22
|
+
response = client.retrieve(user_query="How many users signed up last month?", datafile_id="your-datafile-id")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
1. **Get your API key** from [https://auth.snowleopard.ai/account/api_keys](https://auth.snowleopard.ai/account/api_keys)
|
|
28
|
+
2. **Upload your datafiles** at [https://try.snowleopard.ai](https://try.snowleopard.ai)
|
|
29
|
+
3. **Set your API key** via environment variable:
|
|
30
|
+
```bash
|
|
31
|
+
export SNOWLEOPARD_API_KEY="your-api-key"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or pass it directly to the client:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
SnowLeopardClient(api_key="your-api-key")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Synchronous Client
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from snowleopard import SnowLeopardClient
|
|
46
|
+
|
|
47
|
+
with SnowLeopardClient() as client:
|
|
48
|
+
# Get data directly from a natural language query
|
|
49
|
+
response = client.retrieve(user_query="How many superheroes are there?")
|
|
50
|
+
print(response.data)
|
|
51
|
+
|
|
52
|
+
# Stream natural language summary of live data
|
|
53
|
+
for chunk in client.response(user_query="How many superheroes are there?"):
|
|
54
|
+
print(chunk)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Async Client
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from snowleopard import AsyncSnowLeopardClient
|
|
61
|
+
|
|
62
|
+
async with AsyncSnowLeopardClient() as client:
|
|
63
|
+
# Get complete results
|
|
64
|
+
response = await client.retrieve(user_query="How many superheroes are there?")
|
|
65
|
+
print(response.data)
|
|
66
|
+
|
|
67
|
+
# Get streaming results
|
|
68
|
+
async for chunk in client.response(user_query="How many superheroes are there?"):
|
|
69
|
+
print(chunk)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### CLI
|
|
73
|
+
|
|
74
|
+
The SDK includes a command-line interface:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install snowleopard
|
|
78
|
+
snowy retrieve --datafile <datafile-id> "How many records are there?"
|
|
79
|
+
snowy response --datafile <datafile-id> "Summarize the data"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### On Premise Customers
|
|
83
|
+
|
|
84
|
+
For our customers who have a separate deployment per dataset, you should declare <url> explicitly when creating a
|
|
85
|
+
client and omit <datafile id> when querying.
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
```python
|
|
89
|
+
client = SnowLeopardClient(url="https://{your-vm-ip}:{port}", api_key="your-api-key")
|
|
90
|
+
response = client.retrieve(user_query="How many users signed up last month?")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Contributing
|
|
95
|
+
|
|
96
|
+
For SDK developer docs and how to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# copyright 2025 Snow Leopard, Inc
|
|
3
|
+
# released under the MIT license - see LICENSE file
|
|
4
|
+
|
|
5
|
+
from snowleopard.async_client import AsyncSnowLeopardClient
|
|
6
|
+
from snowleopard.client import SnowLeopardClient
|
|
7
|
+
|
|
8
|
+
__version__ = "0.2.0"
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"SnowLeopardClient",
|
|
12
|
+
"AsyncSnowLeopardClient",
|
|
13
|
+
]
|
|
@@ -10,7 +10,7 @@ from snowleopard.client_base import SLClientBase
|
|
|
10
10
|
from snowleopard.models import ResponseDataObjects, RetrieveResponseObjects, parse
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class AsyncSnowLeopardClient(SLClientBase):
|
|
14
14
|
client: httpx.AsyncClient
|
|
15
15
|
|
|
16
16
|
def __init__(
|
|
@@ -26,9 +26,10 @@ class AsyncSnowLeopardPlaygroundClient(SLClientBase):
|
|
|
26
26
|
|
|
27
27
|
async def retrieve(
|
|
28
28
|
self,
|
|
29
|
-
|
|
29
|
+
*,
|
|
30
30
|
user_query: str,
|
|
31
31
|
known_data: Optional[Dict[str, Any]] = None,
|
|
32
|
+
datafile_id: Optional[str] = None,
|
|
32
33
|
) -> RetrieveResponseObjects:
|
|
33
34
|
resp = await self.client.post(
|
|
34
35
|
url=self._build_path(datafile_id, "retrieve"),
|
|
@@ -38,9 +39,10 @@ class AsyncSnowLeopardPlaygroundClient(SLClientBase):
|
|
|
38
39
|
|
|
39
40
|
async def response(
|
|
40
41
|
self,
|
|
41
|
-
|
|
42
|
-
user_query: str,
|
|
42
|
+
*,
|
|
43
43
|
known_data: Optional[Dict[str, Any]] = None,
|
|
44
|
+
user_query: str,
|
|
45
|
+
datafile_id: Optional[str] = None,
|
|
44
46
|
) -> AsyncGenerator[ResponseDataObjects, None]:
|
|
45
47
|
async with self.client.stream(
|
|
46
48
|
"POST",
|
|
@@ -9,7 +9,7 @@ import argparse
|
|
|
9
9
|
from typing import List, Optional, Dict, Any
|
|
10
10
|
|
|
11
11
|
from httpx import HTTPStatusError
|
|
12
|
-
from snowleopard import __version__,
|
|
12
|
+
from snowleopard import __version__, SnowLeopardClient
|
|
13
13
|
from snowleopard.models import RetrieveResponseError
|
|
14
14
|
|
|
15
15
|
|
|
@@ -41,13 +41,15 @@ def _create_parser() -> argparse.ArgumentParser:
|
|
|
41
41
|
response.set_defaults(command_func=_response)
|
|
42
42
|
|
|
43
43
|
for subparser in (retrieve, response):
|
|
44
|
+
subparser.add_argument(
|
|
45
|
+
"--datafile", "-df", type=str, help="ID for playground datafile to query"
|
|
46
|
+
)
|
|
44
47
|
subparser.add_argument(
|
|
45
48
|
"--knownData",
|
|
46
49
|
"-d",
|
|
47
50
|
action="append",
|
|
48
51
|
help="Known data in key=value format (can be specified multiple times)",
|
|
49
52
|
)
|
|
50
|
-
subparser.add_argument("datafile", type=str, help="ID for Datafile to query")
|
|
51
53
|
subparser.add_argument("question", type=str, help="Natural language query")
|
|
52
54
|
|
|
53
55
|
return parser
|
|
@@ -60,7 +62,10 @@ def _parse_known_data(known_data_list: Optional[List[str]]) -> Optional[Dict[str
|
|
|
60
62
|
result = {}
|
|
61
63
|
for item in known_data_list:
|
|
62
64
|
if "=" not in item:
|
|
63
|
-
print(
|
|
65
|
+
print(
|
|
66
|
+
f"Error: Invalid knownData format '{item}'. Expected key=value",
|
|
67
|
+
file=sys.stderr,
|
|
68
|
+
)
|
|
64
69
|
sys.exit(1)
|
|
65
70
|
key, value = item.split("=", 1)
|
|
66
71
|
result[key] = value
|
|
@@ -69,7 +74,7 @@ def _parse_known_data(known_data_list: Optional[List[str]]) -> Optional[Dict[str
|
|
|
69
74
|
|
|
70
75
|
def _get_client(parsed_args):
|
|
71
76
|
try:
|
|
72
|
-
client =
|
|
77
|
+
client = SnowLeopardClient(api_key=parsed_args.apikey, loc=parsed_args.loc)
|
|
73
78
|
except Exception as e:
|
|
74
79
|
print(str(e), file=sys.stderr)
|
|
75
80
|
sys.exit(1)
|
|
@@ -80,7 +85,11 @@ def _retrieve(parsed_args):
|
|
|
80
85
|
try:
|
|
81
86
|
known_data = _parse_known_data(parsed_args.knownData)
|
|
82
87
|
with _get_client(parsed_args) as client:
|
|
83
|
-
resp = client.retrieve(
|
|
88
|
+
resp = client.retrieve(
|
|
89
|
+
user_query=parsed_args.question,
|
|
90
|
+
known_data=known_data,
|
|
91
|
+
datafile_id=parsed_args.datafile,
|
|
92
|
+
)
|
|
84
93
|
print(json.dumps(dataclasses.asdict(resp)))
|
|
85
94
|
if isinstance(resp, RetrieveResponseError):
|
|
86
95
|
sys.exit(1)
|
|
@@ -93,7 +102,11 @@ def _response(parsed_args):
|
|
|
93
102
|
try:
|
|
94
103
|
known_data = _parse_known_data(parsed_args.knownData)
|
|
95
104
|
with _get_client(parsed_args) as client:
|
|
96
|
-
for chunk in client.response(
|
|
105
|
+
for chunk in client.response(
|
|
106
|
+
known_data=known_data,
|
|
107
|
+
user_query=parsed_args.question,
|
|
108
|
+
datafile_id=parsed_args.datafile,
|
|
109
|
+
):
|
|
97
110
|
print(json.dumps(dataclasses.asdict(chunk)))
|
|
98
111
|
except HTTPStatusError as e:
|
|
99
112
|
print(str(e), file=sys.stderr)
|
|
@@ -10,7 +10,7 @@ from snowleopard.client_base import SLClientBase
|
|
|
10
10
|
from snowleopard.models import parse, RetrieveResponseObjects, ResponseDataObjects
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class SnowLeopardClient(SLClientBase):
|
|
14
14
|
client: httpx.Client
|
|
15
15
|
|
|
16
16
|
def __init__(
|
|
@@ -26,9 +26,10 @@ class SnowLeopardPlaygroundClient(SLClientBase):
|
|
|
26
26
|
|
|
27
27
|
def retrieve(
|
|
28
28
|
self,
|
|
29
|
-
|
|
29
|
+
*,
|
|
30
30
|
user_query: str,
|
|
31
31
|
known_data: Optional[Dict[str, Any]] = None,
|
|
32
|
+
datafile_id: Optional[str] = None,
|
|
32
33
|
) -> RetrieveResponseObjects:
|
|
33
34
|
resp = self.client.post(
|
|
34
35
|
url=self._build_path(datafile_id, "retrieve"),
|
|
@@ -40,9 +41,10 @@ class SnowLeopardPlaygroundClient(SLClientBase):
|
|
|
40
41
|
|
|
41
42
|
def response(
|
|
42
43
|
self,
|
|
43
|
-
|
|
44
|
-
user_query: str,
|
|
44
|
+
*,
|
|
45
45
|
known_data: Optional[Dict[str, Any]] = None,
|
|
46
|
+
user_query: str,
|
|
47
|
+
datafile_id: Optional[str] = None,
|
|
46
48
|
) -> Generator[ResponseDataObjects, None, None]:
|
|
47
49
|
with self.client.stream(
|
|
48
50
|
"POST",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# released under the MIT license - see LICENSE file
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
+
from abc import abstractmethod
|
|
6
7
|
from dataclasses import dataclass
|
|
7
8
|
from typing import Optional, Dict, Any
|
|
8
9
|
|
|
@@ -25,6 +26,44 @@ class SLConfig:
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class SLClientBase:
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def retrieve(
|
|
31
|
+
self,
|
|
32
|
+
*,
|
|
33
|
+
user_query: str,
|
|
34
|
+
known_data: Optional[Dict[str, Any]] = None,
|
|
35
|
+
datafile_id: Optional[str] = None,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
The primary for developers building AI agents that needs to retrieve data from a database directly.
|
|
39
|
+
|
|
40
|
+
Takes a natural language question (usually from the user or the agent) and returns the data required to answer
|
|
41
|
+
the query in an LLM-friendly object.
|
|
42
|
+
|
|
43
|
+
:param datafile_id: (optional) The playground datafile-id if hitting a Snow Leopard api directly
|
|
44
|
+
:param user_query: Natural language query to execute against the Playground datafile
|
|
45
|
+
:param known_data: Additional context about the user_query
|
|
46
|
+
"""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def response(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
known_data: Optional[Dict[str, Any]] = None,
|
|
54
|
+
user_query: str,
|
|
55
|
+
datafile_id: Optional[str] = None,
|
|
56
|
+
):
|
|
57
|
+
"""
|
|
58
|
+
Takes a natural language question (usually from the user or the agent) and returns the data required to answer
|
|
59
|
+
the query as well as a LLM summary of the returned data.
|
|
60
|
+
|
|
61
|
+
:param datafile_id: (optional) The playground datafile-id if hitting a Snow Leopard api directly
|
|
62
|
+
:param user_query: Natural language query to execute against the Playground datafile
|
|
63
|
+
:param known_data: (optional) Additional context about the user_query
|
|
64
|
+
"""
|
|
65
|
+
...
|
|
66
|
+
|
|
28
67
|
@staticmethod
|
|
29
68
|
def _config(
|
|
30
69
|
api_key: Optional[str], timeout: Optional[httpx.Timeout], loc: Optional[str]
|
|
@@ -46,7 +85,10 @@ class SLClientBase:
|
|
|
46
85
|
|
|
47
86
|
@staticmethod
|
|
48
87
|
def _build_path(datafile_id: str, endpoint: str) -> str:
|
|
49
|
-
|
|
88
|
+
if datafile_id is None:
|
|
89
|
+
return endpoint
|
|
90
|
+
else:
|
|
91
|
+
return f"datafiles/{datafile_id}/{endpoint}"
|
|
50
92
|
|
|
51
93
|
@staticmethod
|
|
52
94
|
def _build_request_body(
|
snowleopard-0.1.1/README.md
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# Snow Leopard SDK for Python
|
|
2
|
-
|
|
3
|
-
Python client library for [Snow Leopard Playground](https://try.snowleopard.ai) APIs.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install snowleopard
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```python
|
|
14
|
-
from snowleopard import SnowLeopardPlaygroundClient
|
|
15
|
-
|
|
16
|
-
# Initialize the client (or AsyncSnowLeopardPlaygroundClient)
|
|
17
|
-
client = SnowLeopardPlaygroundClient(api_key="your-api-key")
|
|
18
|
-
|
|
19
|
-
# Query your data in natural language
|
|
20
|
-
response = client.retrieve(
|
|
21
|
-
datafile_id="your-datafile-id",
|
|
22
|
-
user_query="How many users signed up last month?"
|
|
23
|
-
)
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Getting Started
|
|
27
|
-
|
|
28
|
-
1. **Get your API key** from [https://auth.snowleopard.ai/account/api_keys](https://auth.snowleopard.ai/account/api_keys)
|
|
29
|
-
2. **Upload your datafiles** at [https://try.snowleopard.ai](https://try.snowleopard.ai)
|
|
30
|
-
3. **Set your API key** via environment variable:
|
|
31
|
-
```bash
|
|
32
|
-
export SNOWLEOPARD_API_KEY="your-api-key"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Or pass it directly to the client:
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
SnowLeopardPlaygroundClient(api_key="your-api-key")
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Usage
|
|
42
|
-
|
|
43
|
-
### Synchronous Client
|
|
44
|
-
|
|
45
|
-
```python
|
|
46
|
-
from snowleopard import SnowLeopardPlaygroundClient
|
|
47
|
-
|
|
48
|
-
with SnowLeopardPlaygroundClient() as client:
|
|
49
|
-
# Get data directly from a natural language query
|
|
50
|
-
response = client.retrieve("datafile-id", "What's the total revenue?")
|
|
51
|
-
print(response.data)
|
|
52
|
-
|
|
53
|
-
# Stream natural language summary of live data
|
|
54
|
-
for chunk in client.response("datafile-id", "Show me top 10 customers"):
|
|
55
|
-
print(chunk)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Async Client
|
|
59
|
-
|
|
60
|
-
```python
|
|
61
|
-
from snowleopard import AsyncSnowLeopardPlaygroundClient
|
|
62
|
-
|
|
63
|
-
async with AsyncSnowLeopardPlaygroundClient() as client:
|
|
64
|
-
# Get complete results
|
|
65
|
-
response = await client.retrieve("datafile-id", "What's the total revenue?")
|
|
66
|
-
print(response.data)
|
|
67
|
-
|
|
68
|
-
# Get streaming results
|
|
69
|
-
async for chunk in client.response("datafile-id", "Show me top 10 customers"):
|
|
70
|
-
print(chunk)
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### CLI
|
|
74
|
-
|
|
75
|
-
The SDK includes a command-line interface:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
pip install snowleopard
|
|
79
|
-
snowy retrieve <datafile-id> "How many records are there?"
|
|
80
|
-
snowy response <datafile-id> "Summarize the data"
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Contributing
|
|
84
|
-
|
|
85
|
-
For SDK developer docs and how to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# copyright 2025 Snow Leopard, Inc
|
|
3
|
-
# released under the MIT license - see LICENSE file
|
|
4
|
-
|
|
5
|
-
from snowleopard.async_client import AsyncSnowLeopardPlaygroundClient
|
|
6
|
-
from snowleopard.client import SnowLeopardPlaygroundClient
|
|
7
|
-
|
|
8
|
-
__version__ = "0.1.1"
|
|
9
|
-
|
|
10
|
-
__all__ = [
|
|
11
|
-
"SnowLeopardPlaygroundClient",
|
|
12
|
-
"AsyncSnowLeopardPlaygroundClient",
|
|
13
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|