snowglobe 0.0.7__tar.gz → 0.4.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.
- snowglobe-0.4.1/LICENSE +21 -0
- snowglobe-0.4.1/PKG-INFO +121 -0
- snowglobe-0.4.1/README.md +76 -0
- snowglobe-0.4.1/pyproject.toml +139 -0
- snowglobe-0.4.1/src/snowglobe/client/__init__.py +17 -0
- snowglobe-0.4.1/src/snowglobe/client/src/app.py +732 -0
- snowglobe-0.4.1/src/snowglobe/client/src/cli.py +736 -0
- snowglobe-0.4.1/src/snowglobe/client/src/cli_utils.py +361 -0
- snowglobe-0.4.1/src/snowglobe/client/src/config.py +213 -0
- snowglobe-0.4.1/src/snowglobe/client/src/models.py +37 -0
- snowglobe-0.4.1/src/snowglobe/client/src/project_manager.py +290 -0
- snowglobe-0.4.1/src/snowglobe/client/src/stats.py +53 -0
- snowglobe-0.4.1/src/snowglobe/client/src/utils.py +117 -0
- snowglobe-0.4.1/src/snowglobe.egg-info/PKG-INFO +121 -0
- snowglobe-0.4.1/src/snowglobe.egg-info/SOURCES.txt +23 -0
- snowglobe-0.4.1/src/snowglobe.egg-info/entry_points.txt +2 -0
- snowglobe-0.4.1/src/snowglobe.egg-info/requires.txt +14 -0
- snowglobe-0.4.1/tests/test_app.py +421 -0
- snowglobe-0.4.1/tests/test_cli.py +655 -0
- snowglobe-0.4.1/tests/test_config.py +141 -0
- snowglobe-0.4.1/tests/test_heartbeat.py +35 -0
- snowglobe-0.4.1/tests/test_utils.py +87 -0
- snowglobe-0.0.7/PKG-INFO +0 -294
- snowglobe-0.0.7/README.md +0 -279
- snowglobe-0.0.7/setup.py +0 -31
- snowglobe-0.0.7/snowglobe/__init__.py +0 -0
- snowglobe-0.0.7/snowglobe/__main__.py +0 -111
- snowglobe-0.0.7/snowglobe/config.py +0 -170
- snowglobe-0.0.7/snowglobe/configs/README +0 -1
- snowglobe-0.0.7/snowglobe/environment.py +0 -136
- snowglobe-0.0.7/snowglobe/runtime.py +0 -109
- snowglobe-0.0.7/snowglobe.egg-info/PKG-INFO +0 -294
- snowglobe-0.0.7/snowglobe.egg-info/SOURCES.txt +0 -14
- snowglobe-0.0.7/snowglobe.egg-info/entry_points.txt +0 -3
- snowglobe-0.0.7/snowglobe.egg-info/requires.txt +0 -1
- {snowglobe-0.0.7 → snowglobe-0.4.1}/setup.cfg +0 -0
- {snowglobe-0.0.7 → snowglobe-0.4.1/src}/snowglobe.egg-info/dependency_links.txt +0 -0
- {snowglobe-0.0.7 → snowglobe-0.4.1/src}/snowglobe.egg-info/top_level.txt +0 -0
snowglobe-0.4.1/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Guardrails AI
|
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.
|
snowglobe-0.4.1/PKG-INFO
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: snowglobe
|
3
|
+
Version: 0.4.1
|
4
|
+
Summary: client server for usage with snowglobe experiments
|
5
|
+
Author-email: Guardrails AI <contact@guardrailsai.com>
|
6
|
+
License: MIT License
|
7
|
+
|
8
|
+
Copyright (c) 2024 Guardrails AI
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
Requires-Python: >=3.9
|
29
|
+
Description-Content-Type: text/markdown
|
30
|
+
License-File: LICENSE
|
31
|
+
Requires-Dist: typer>=0.9.0
|
32
|
+
Requires-Dist: fastapi>=0.115.6
|
33
|
+
Requires-Dist: uvicorn[standard]>=0.23.0
|
34
|
+
Requires-Dist: requests>=2.31.0
|
35
|
+
Requires-Dist: pydantic>=2.11.5
|
36
|
+
Requires-Dist: APScheduler==4.0.0a6
|
37
|
+
Requires-Dist: httpx==0.28.1
|
38
|
+
Requires-Dist: rich>=13.0.0
|
39
|
+
Provides-Extra: dev
|
40
|
+
Requires-Dist: ruff<0.2.0,>=0.1.0; extra == "dev"
|
41
|
+
Requires-Dist: mypy<2.0.0,>=1.5.0; extra == "dev"
|
42
|
+
Requires-Dist: pre-commit>=4.1.0; extra == "dev"
|
43
|
+
Requires-Dist: coverage>=7.6.12; extra == "dev"
|
44
|
+
Dynamic: license-file
|
45
|
+
|
46
|
+
# Snowlgobe Connect SDK
|
47
|
+
|
48
|
+
The Snowglobe Connect SDK helps you connect your AI agents to Snowglobe. It sends simulated user messages to your LLM-based application during experiments. Your application should process these messages and return a response, enabling simulated conversations and custom code based risk assessment.
|
49
|
+
|
50
|
+
## Installation
|
51
|
+
|
52
|
+
```
|
53
|
+
# Install client
|
54
|
+
pip install snowglobe-connect
|
55
|
+
```
|
56
|
+
|
57
|
+
If using uv, set the `--prerelease=allow` flag
|
58
|
+
```
|
59
|
+
uv pip install --prerelease=allow snowglobe-connect
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
## `snowglobe-connect` commands
|
64
|
+
|
65
|
+
```bash
|
66
|
+
snowglobe-connect auth # Sets up your API key
|
67
|
+
snowglobe-connect init # Initializes a new agent connection and creates an agent wrapper file
|
68
|
+
snowglobe-connect test # Tests your agent connection
|
69
|
+
snowglobe-connect start # Starts the process of processing simulated user messages
|
70
|
+
snowglobe-connect --help
|
71
|
+
```
|
72
|
+
|
73
|
+
When using one of our specific preview environments in .snowgloberc one can override our server's URL with:
|
74
|
+
|
75
|
+
```bash
|
76
|
+
CONTROL_PLANE_URL=
|
77
|
+
```
|
78
|
+
|
79
|
+
## Sample custom llm usage in agent wrapper file
|
80
|
+
|
81
|
+
Each agent wrapper file resides in the root directory of your project, and is named after the agent (e.g. `My Agent Name` becomes `my_agent_name.py`).
|
82
|
+
|
83
|
+
```python
|
84
|
+
from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
|
85
|
+
from openai import OpenAI
|
86
|
+
import os
|
87
|
+
|
88
|
+
client = OpenAI(api_key=os.getenv("SNOWGLOBE_API_KEY"))
|
89
|
+
|
90
|
+
def process_scenario(request: CompletionRequest) -> CompletionFunctionOutputs:
|
91
|
+
"""
|
92
|
+
Process a scenario request from Snowglobe.
|
93
|
+
|
94
|
+
This function is called by the Snowglobe client to process requests. It should return a
|
95
|
+
CompletionFunctionOutputs object with the response content.
|
96
|
+
|
97
|
+
Example CompletionRequest:
|
98
|
+
CompletionRequest(
|
99
|
+
messages=[
|
100
|
+
SnowglobeMessage(role="user", content="Hello, how are you?", snowglobe_data=None),
|
101
|
+
]
|
102
|
+
)
|
103
|
+
|
104
|
+
Example CompletionFunctionOutputs:
|
105
|
+
CompletionFunctionOutputs(response="This is a string response from your application")
|
106
|
+
|
107
|
+
Args:
|
108
|
+
request (CompletionRequest): The request object containing the messages.
|
109
|
+
|
110
|
+
Returns:
|
111
|
+
CompletionFunctionOutputs: The response object with the generated content.
|
112
|
+
"""
|
113
|
+
|
114
|
+
# Process the request using the messages. Example:
|
115
|
+
messages = request.to_openai_messages()
|
116
|
+
response = client.chat.completions.create(
|
117
|
+
model="gpt-4o-mini",
|
118
|
+
messages=messages
|
119
|
+
)
|
120
|
+
return CompletionFunctionOutputs(response=response.choices[0].message.content)
|
121
|
+
```
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Snowlgobe Connect SDK
|
2
|
+
|
3
|
+
The Snowglobe Connect SDK helps you connect your AI agents to Snowglobe. It sends simulated user messages to your LLM-based application during experiments. Your application should process these messages and return a response, enabling simulated conversations and custom code based risk assessment.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
# Install client
|
9
|
+
pip install snowglobe-connect
|
10
|
+
```
|
11
|
+
|
12
|
+
If using uv, set the `--prerelease=allow` flag
|
13
|
+
```
|
14
|
+
uv pip install --prerelease=allow snowglobe-connect
|
15
|
+
```
|
16
|
+
|
17
|
+
|
18
|
+
## `snowglobe-connect` commands
|
19
|
+
|
20
|
+
```bash
|
21
|
+
snowglobe-connect auth # Sets up your API key
|
22
|
+
snowglobe-connect init # Initializes a new agent connection and creates an agent wrapper file
|
23
|
+
snowglobe-connect test # Tests your agent connection
|
24
|
+
snowglobe-connect start # Starts the process of processing simulated user messages
|
25
|
+
snowglobe-connect --help
|
26
|
+
```
|
27
|
+
|
28
|
+
When using one of our specific preview environments in .snowgloberc one can override our server's URL with:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
CONTROL_PLANE_URL=
|
32
|
+
```
|
33
|
+
|
34
|
+
## Sample custom llm usage in agent wrapper file
|
35
|
+
|
36
|
+
Each agent wrapper file resides in the root directory of your project, and is named after the agent (e.g. `My Agent Name` becomes `my_agent_name.py`).
|
37
|
+
|
38
|
+
```python
|
39
|
+
from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
|
40
|
+
from openai import OpenAI
|
41
|
+
import os
|
42
|
+
|
43
|
+
client = OpenAI(api_key=os.getenv("SNOWGLOBE_API_KEY"))
|
44
|
+
|
45
|
+
def process_scenario(request: CompletionRequest) -> CompletionFunctionOutputs:
|
46
|
+
"""
|
47
|
+
Process a scenario request from Snowglobe.
|
48
|
+
|
49
|
+
This function is called by the Snowglobe client to process requests. It should return a
|
50
|
+
CompletionFunctionOutputs object with the response content.
|
51
|
+
|
52
|
+
Example CompletionRequest:
|
53
|
+
CompletionRequest(
|
54
|
+
messages=[
|
55
|
+
SnowglobeMessage(role="user", content="Hello, how are you?", snowglobe_data=None),
|
56
|
+
]
|
57
|
+
)
|
58
|
+
|
59
|
+
Example CompletionFunctionOutputs:
|
60
|
+
CompletionFunctionOutputs(response="This is a string response from your application")
|
61
|
+
|
62
|
+
Args:
|
63
|
+
request (CompletionRequest): The request object containing the messages.
|
64
|
+
|
65
|
+
Returns:
|
66
|
+
CompletionFunctionOutputs: The response object with the generated content.
|
67
|
+
"""
|
68
|
+
|
69
|
+
# Process the request using the messages. Example:
|
70
|
+
messages = request.to_openai_messages()
|
71
|
+
response = client.chat.completions.create(
|
72
|
+
model="gpt-4o-mini",
|
73
|
+
messages=messages
|
74
|
+
)
|
75
|
+
return CompletionFunctionOutputs(response=response.choices[0].message.content)
|
76
|
+
```
|
@@ -0,0 +1,139 @@
|
|
1
|
+
[project]
|
2
|
+
name = "snowglobe"
|
3
|
+
version = "0.4.1"
|
4
|
+
authors = [
|
5
|
+
{name = "Guardrails AI", email = "contact@guardrailsai.com"}
|
6
|
+
]
|
7
|
+
license = {file = "LICENSE"}
|
8
|
+
|
9
|
+
description = "client server for usage with snowglobe experiments"
|
10
|
+
readme = "README.md"
|
11
|
+
requires-python = ">= 3.9"
|
12
|
+
|
13
|
+
dependencies = [
|
14
|
+
"typer>=0.9.0",
|
15
|
+
"fastapi>=0.115.6",
|
16
|
+
"uvicorn[standard]>=0.23.0",
|
17
|
+
"requests>=2.31.0",
|
18
|
+
"pydantic>=2.11.5",
|
19
|
+
"APScheduler==4.0.0a6",
|
20
|
+
"httpx==0.28.1",
|
21
|
+
"rich>=13.0.0"
|
22
|
+
]
|
23
|
+
|
24
|
+
[project.optional-dependencies]
|
25
|
+
dev = [
|
26
|
+
|
27
|
+
"ruff>=0.1.0,<0.2.0",
|
28
|
+
"mypy>=1.5.0,<2.0.0",
|
29
|
+
"pre-commit>=4.1.0",
|
30
|
+
"coverage>=7.6.12"
|
31
|
+
]
|
32
|
+
|
33
|
+
[project.scripts]
|
34
|
+
snowglobe-connect = "snowglobe.client.src.cli:cli_app"
|
35
|
+
|
36
|
+
[build-system]
|
37
|
+
requires = ["setuptools"]
|
38
|
+
build-backend = "setuptools.build_meta"
|
39
|
+
|
40
|
+
[tool.ruff]
|
41
|
+
# Exclude a variety of commonly ignored directories.
|
42
|
+
exclude = [
|
43
|
+
".bzr",
|
44
|
+
".direnv",
|
45
|
+
".eggs",
|
46
|
+
".git",
|
47
|
+
".git-rewrite",
|
48
|
+
".hg",
|
49
|
+
".ipynb_checkpoints",
|
50
|
+
".mypy_cache",
|
51
|
+
".nox",
|
52
|
+
".pants.d",
|
53
|
+
".pyenv",
|
54
|
+
".pytest_cache",
|
55
|
+
".pytype",
|
56
|
+
".ruff_cache",
|
57
|
+
".svn",
|
58
|
+
".tox",
|
59
|
+
".venv",
|
60
|
+
".vscode",
|
61
|
+
"__pypackages__",
|
62
|
+
"_build",
|
63
|
+
"buck-out",
|
64
|
+
"build",
|
65
|
+
"dist",
|
66
|
+
"node_modules",
|
67
|
+
"site-packages",
|
68
|
+
"venv",
|
69
|
+
]
|
70
|
+
|
71
|
+
# Same as Black.
|
72
|
+
line-length = 88
|
73
|
+
indent-width = 4
|
74
|
+
|
75
|
+
target-version = "py39"
|
76
|
+
|
77
|
+
|
78
|
+
[tool.ruff.lint]
|
79
|
+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
80
|
+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
81
|
+
# McCabe complexity (`C901`) by default.
|
82
|
+
select = ["E4", "E7", "E9", "F"]
|
83
|
+
ignore = []
|
84
|
+
|
85
|
+
# Allow fix for all enabled rules (when `--fix`) is provided.
|
86
|
+
fixable = ["ALL"]
|
87
|
+
unfixable = []
|
88
|
+
|
89
|
+
# Allow unused variables when underscore-prefixed.
|
90
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
91
|
+
|
92
|
+
[tool.ruff.format]
|
93
|
+
# Like Black, use double quotes for strings.
|
94
|
+
quote-style = "double"
|
95
|
+
|
96
|
+
# Like Black, indent with spaces, rather than tabs.
|
97
|
+
indent-style = "space"
|
98
|
+
|
99
|
+
# Like Black, respect magic trailing commas.
|
100
|
+
skip-magic-trailing-comma = false
|
101
|
+
|
102
|
+
# Like Black, automatically detect the appropriate line ending.
|
103
|
+
line-ending = "auto"
|
104
|
+
|
105
|
+
# Enable auto-formatting of code examples in docstrings. Markdown,
|
106
|
+
# reStructuredText code/literal blocks and doctests are all supported.
|
107
|
+
#
|
108
|
+
# This is currently disabled by default, but it is planned for this
|
109
|
+
# to be opt-out in the future.
|
110
|
+
docstring-code-format = false
|
111
|
+
|
112
|
+
# Set the line length limit used when formatting code snippets in
|
113
|
+
# docstrings.
|
114
|
+
#
|
115
|
+
# This only has an effect when the `docstring-code-format` setting is
|
116
|
+
# enabled.
|
117
|
+
docstring-code-line-length = "dynamic"
|
118
|
+
|
119
|
+
[tool.coverage.run]
|
120
|
+
omit = [
|
121
|
+
"tests/*",
|
122
|
+
"/tmp/*",
|
123
|
+
"*/tmp*",
|
124
|
+
"/private/var/folders/*"
|
125
|
+
]
|
126
|
+
|
127
|
+
[tool.mypy]
|
128
|
+
python_version = "3.9"
|
129
|
+
warn_return_any = true
|
130
|
+
warn_unused_configs = true
|
131
|
+
disallow_untyped_defs = true
|
132
|
+
disallow_incomplete_defs = true
|
133
|
+
check_untyped_defs = true
|
134
|
+
disallow_untyped_decorators = true
|
135
|
+
no_implicit_optional = true
|
136
|
+
warn_redundant_casts = true
|
137
|
+
warn_unused_ignores = true
|
138
|
+
warn_no_return = true
|
139
|
+
warn_unreachable = true
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from .src.models import (
|
2
|
+
SnowglobeData,
|
3
|
+
SnowglobeMessage,
|
4
|
+
CompletionFunctionOutputs,
|
5
|
+
CompletionRequest,
|
6
|
+
RiskEvaluationRequest,
|
7
|
+
RiskEvaluationOutputs,
|
8
|
+
)
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"SnowglobeData",
|
12
|
+
"SnowglobeMessage",
|
13
|
+
"CompletionFunctionOutputs",
|
14
|
+
"CompletionRequest",
|
15
|
+
"RiskEvaluationRequest",
|
16
|
+
"RiskEvaluationOutputs",
|
17
|
+
]
|