snowglobe 0.0.7__tar.gz → 0.4.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.
Files changed (38) hide show
  1. snowglobe-0.4.0/LICENSE +21 -0
  2. snowglobe-0.4.0/PKG-INFO +128 -0
  3. snowglobe-0.4.0/README.md +83 -0
  4. snowglobe-0.4.0/pyproject.toml +139 -0
  5. snowglobe-0.4.0/src/snowglobe/client/__init__.py +17 -0
  6. snowglobe-0.4.0/src/snowglobe/client/src/app.py +732 -0
  7. snowglobe-0.4.0/src/snowglobe/client/src/cli.py +736 -0
  8. snowglobe-0.4.0/src/snowglobe/client/src/cli_utils.py +361 -0
  9. snowglobe-0.4.0/src/snowglobe/client/src/config.py +213 -0
  10. snowglobe-0.4.0/src/snowglobe/client/src/models.py +37 -0
  11. snowglobe-0.4.0/src/snowglobe/client/src/project_manager.py +290 -0
  12. snowglobe-0.4.0/src/snowglobe/client/src/stats.py +53 -0
  13. snowglobe-0.4.0/src/snowglobe/client/src/utils.py +117 -0
  14. snowglobe-0.4.0/src/snowglobe.egg-info/PKG-INFO +128 -0
  15. snowglobe-0.4.0/src/snowglobe.egg-info/SOURCES.txt +23 -0
  16. snowglobe-0.4.0/src/snowglobe.egg-info/entry_points.txt +2 -0
  17. snowglobe-0.4.0/src/snowglobe.egg-info/requires.txt +14 -0
  18. snowglobe-0.4.0/tests/test_app.py +421 -0
  19. snowglobe-0.4.0/tests/test_cli.py +655 -0
  20. snowglobe-0.4.0/tests/test_config.py +141 -0
  21. snowglobe-0.4.0/tests/test_heartbeat.py +35 -0
  22. snowglobe-0.4.0/tests/test_utils.py +87 -0
  23. snowglobe-0.0.7/PKG-INFO +0 -294
  24. snowglobe-0.0.7/README.md +0 -279
  25. snowglobe-0.0.7/setup.py +0 -31
  26. snowglobe-0.0.7/snowglobe/__init__.py +0 -0
  27. snowglobe-0.0.7/snowglobe/__main__.py +0 -111
  28. snowglobe-0.0.7/snowglobe/config.py +0 -170
  29. snowglobe-0.0.7/snowglobe/configs/README +0 -1
  30. snowglobe-0.0.7/snowglobe/environment.py +0 -136
  31. snowglobe-0.0.7/snowglobe/runtime.py +0 -109
  32. snowglobe-0.0.7/snowglobe.egg-info/PKG-INFO +0 -294
  33. snowglobe-0.0.7/snowglobe.egg-info/SOURCES.txt +0 -14
  34. snowglobe-0.0.7/snowglobe.egg-info/entry_points.txt +0 -3
  35. snowglobe-0.0.7/snowglobe.egg-info/requires.txt +0 -1
  36. {snowglobe-0.0.7 → snowglobe-0.4.0}/setup.cfg +0 -0
  37. {snowglobe-0.0.7 → snowglobe-0.4.0/src}/snowglobe.egg-info/dependency_links.txt +0 -0
  38. {snowglobe-0.0.7 → snowglobe-0.4.0/src}/snowglobe.egg-info/top_level.txt +0 -0
@@ -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.
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: snowglobe
3
+ Version: 0.4.0
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
+ ```bash
53
+ # Paste Guardrails Client or extract from guardrailsrc
54
+ export GUARDRAILS_TOKEN=$(cat ~/.guardrailsrc| awk -F 'token=' '{print $2}' | awk '{print $1}' | tr -d '\n')
55
+ ```
56
+
57
+ ```
58
+ # Install client
59
+ pip install -U --index-url="https://__token__:$GUARDRAILS_TOKEN@pypi.guardrailsai.com/simple" \
60
+ --extra-index-url="https://pypi.org/simple" snowglobe-connect
61
+ ```
62
+
63
+ If using uv, set the `--prerelease=allow` flag
64
+ ```
65
+ pip install -U --index-url="https://__token__:$GUARDRAILS_TOKEN@pypi.guardrailsai.com/simple" \
66
+ --extra-index-url="https://pypi.org/simple" --prerelease=allow snowglobe-connect
67
+ ```
68
+
69
+
70
+ ## `snowglobe-connect` commands
71
+
72
+ ```bash
73
+ snowglobe-connect auth # Sets up your API key
74
+ snowglobe-connect init # Initializes a new agent connection and creates an agent wrapper file
75
+ snowglobe-connect test # Tests your agent connection
76
+ snowglobe-connect start # Starts the process of processing simulated user messages
77
+ snowglobe-connect --help
78
+ ```
79
+
80
+ When using one of our specific preview environments in .snowgloberc one can override our server's URL with:
81
+
82
+ ```bash
83
+ CONTROL_PLANE_URL=
84
+ ```
85
+
86
+ ## Sample custom llm usage in agent wrapper file
87
+
88
+ 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`).
89
+
90
+ ```python
91
+ from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
92
+ from openai import OpenAI
93
+ import os
94
+
95
+ client = OpenAI(api_key=os.getenv("SNOWGLOBE_API_KEY"))
96
+
97
+ def process_scenario(request: CompletionRequest) -> CompletionFunctionOutputs:
98
+ """
99
+ Process a scenario request from Snowglobe.
100
+
101
+ This function is called by the Snowglobe client to process requests. It should return a
102
+ CompletionFunctionOutputs object with the response content.
103
+
104
+ Example CompletionRequest:
105
+ CompletionRequest(
106
+ messages=[
107
+ SnowglobeMessage(role="user", content="Hello, how are you?", snowglobe_data=None),
108
+ ]
109
+ )
110
+
111
+ Example CompletionFunctionOutputs:
112
+ CompletionFunctionOutputs(response="This is a string response from your application")
113
+
114
+ Args:
115
+ request (CompletionRequest): The request object containing the messages.
116
+
117
+ Returns:
118
+ CompletionFunctionOutputs: The response object with the generated content.
119
+ """
120
+
121
+ # Process the request using the messages. Example:
122
+ messages = request.to_openai_messages()
123
+ response = client.chat.completions.create(
124
+ model="gpt-4o-mini",
125
+ messages=messages
126
+ )
127
+ return CompletionFunctionOutputs(response=response.choices[0].message.content)
128
+ ```
@@ -0,0 +1,83 @@
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
+ ```bash
8
+ # Paste Guardrails Client or extract from guardrailsrc
9
+ export GUARDRAILS_TOKEN=$(cat ~/.guardrailsrc| awk -F 'token=' '{print $2}' | awk '{print $1}' | tr -d '\n')
10
+ ```
11
+
12
+ ```
13
+ # Install client
14
+ pip install -U --index-url="https://__token__:$GUARDRAILS_TOKEN@pypi.guardrailsai.com/simple" \
15
+ --extra-index-url="https://pypi.org/simple" snowglobe-connect
16
+ ```
17
+
18
+ If using uv, set the `--prerelease=allow` flag
19
+ ```
20
+ pip install -U --index-url="https://__token__:$GUARDRAILS_TOKEN@pypi.guardrailsai.com/simple" \
21
+ --extra-index-url="https://pypi.org/simple" --prerelease=allow snowglobe-connect
22
+ ```
23
+
24
+
25
+ ## `snowglobe-connect` commands
26
+
27
+ ```bash
28
+ snowglobe-connect auth # Sets up your API key
29
+ snowglobe-connect init # Initializes a new agent connection and creates an agent wrapper file
30
+ snowglobe-connect test # Tests your agent connection
31
+ snowglobe-connect start # Starts the process of processing simulated user messages
32
+ snowglobe-connect --help
33
+ ```
34
+
35
+ When using one of our specific preview environments in .snowgloberc one can override our server's URL with:
36
+
37
+ ```bash
38
+ CONTROL_PLANE_URL=
39
+ ```
40
+
41
+ ## Sample custom llm usage in agent wrapper file
42
+
43
+ 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`).
44
+
45
+ ```python
46
+ from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
47
+ from openai import OpenAI
48
+ import os
49
+
50
+ client = OpenAI(api_key=os.getenv("SNOWGLOBE_API_KEY"))
51
+
52
+ def process_scenario(request: CompletionRequest) -> CompletionFunctionOutputs:
53
+ """
54
+ Process a scenario request from Snowglobe.
55
+
56
+ This function is called by the Snowglobe client to process requests. It should return a
57
+ CompletionFunctionOutputs object with the response content.
58
+
59
+ Example CompletionRequest:
60
+ CompletionRequest(
61
+ messages=[
62
+ SnowglobeMessage(role="user", content="Hello, how are you?", snowglobe_data=None),
63
+ ]
64
+ )
65
+
66
+ Example CompletionFunctionOutputs:
67
+ CompletionFunctionOutputs(response="This is a string response from your application")
68
+
69
+ Args:
70
+ request (CompletionRequest): The request object containing the messages.
71
+
72
+ Returns:
73
+ CompletionFunctionOutputs: The response object with the generated content.
74
+ """
75
+
76
+ # Process the request using the messages. Example:
77
+ messages = request.to_openai_messages()
78
+ response = client.chat.completions.create(
79
+ model="gpt-4o-mini",
80
+ messages=messages
81
+ )
82
+ return CompletionFunctionOutputs(response=response.choices[0].message.content)
83
+ ```
@@ -0,0 +1,139 @@
1
+ [project]
2
+ name = "snowglobe"
3
+ version = "0.4.0"
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
+ ]