opengradient 0.3.18__tar.gz → 0.3.21__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.
- {opengradient-0.3.18 → opengradient-0.3.21}/PKG-INFO +103 -102
- opengradient-0.3.21/pyproject.toml +151 -0
- opengradient-0.3.21/setup.cfg +4 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/__init__.py +4 -3
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/llm/og_langchain.py +3 -2
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/llm/og_openai.py +0 -1
- opengradient-0.3.21/src/opengradient/mltools/__init__.py +14 -0
- opengradient-0.3.21/src/opengradient/mltools/model_tool.py +129 -0
- opengradient-0.3.21/src/opengradient.egg-info/PKG-INFO +276 -0
- opengradient-0.3.21/src/opengradient.egg-info/SOURCES.txt +27 -0
- opengradient-0.3.21/src/opengradient.egg-info/dependency_links.txt +1 -0
- opengradient-0.3.21/src/opengradient.egg-info/entry_points.txt +2 -0
- opengradient-0.3.21/src/opengradient.egg-info/requires.txt +97 -0
- opengradient-0.3.21/src/opengradient.egg-info/top_level.txt +1 -0
- opengradient-0.3.18/.gitignore +0 -162
- opengradient-0.3.18/pyproject.toml +0 -159
- {opengradient-0.3.18 → opengradient-0.3.21}/LICENSE +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/README.md +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/abi/inference.abi +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/account.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/cli.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/client.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/defaults.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/exceptions.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/llm/__init__.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/proto/__init__.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/proto/infer.proto +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/proto/infer_pb2.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/proto/infer_pb2_grpc.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/types.py +0 -0
- {opengradient-0.3.18 → opengradient-0.3.21}/src/opengradient/utils.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: opengradient
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.21
|
|
4
4
|
Summary: Python SDK for OpenGradient decentralized model management & inference services
|
|
5
|
-
Project-URL: Homepage, https://opengradient.ai
|
|
6
5
|
Author-email: OpenGradient <oliver@opengradient.ai>
|
|
7
6
|
License: MIT License
|
|
8
7
|
|
|
@@ -25,7 +24,8 @@ License: MIT License
|
|
|
25
24
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
26
|
SOFTWARE.
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://opengradient.ai
|
|
29
29
|
Classifier: Development Status :: 3 - Alpha
|
|
30
30
|
Classifier: Intended Audience :: Developers
|
|
31
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -33,104 +33,105 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
33
33
|
Classifier: Programming Language :: Python :: 3.11
|
|
34
34
|
Classifier: Programming Language :: Python :: 3.12
|
|
35
35
|
Requires-Python: >=3.10
|
|
36
|
-
Requires-Dist: aiohappyeyeballs==2.4.3
|
|
37
|
-
Requires-Dist: aiohttp==3.10.8
|
|
38
|
-
Requires-Dist: aiosignal==1.3.1
|
|
39
|
-
Requires-Dist: annotated-types==0.7.0
|
|
40
|
-
Requires-Dist: attrs==24.2.0
|
|
41
|
-
Requires-Dist: bitarray==2.9.2
|
|
42
|
-
Requires-Dist: cachecontrol==0.14.0
|
|
43
|
-
Requires-Dist: cachetools==5.5.0
|
|
44
|
-
Requires-Dist: certifi==2024.8.30
|
|
45
|
-
Requires-Dist: cffi==1.17.1
|
|
46
|
-
Requires-Dist: charset-normalizer==3.3.2
|
|
47
|
-
Requires-Dist: ckzg==2.0.1
|
|
48
|
-
Requires-Dist: cleo==2.1.0
|
|
49
|
-
Requires-Dist: click==8.1.7
|
|
50
|
-
Requires-Dist: cramjam==2.8.4
|
|
51
|
-
Requires-Dist: crashtest==0.4.1
|
|
52
|
-
Requires-Dist: cryptography==43.0.1
|
|
53
|
-
Requires-Dist: cytoolz==0.12.3
|
|
54
|
-
Requires-Dist: distlib==0.3.8
|
|
55
|
-
Requires-Dist: dulwich==0.21.7
|
|
56
|
-
Requires-Dist: eth-abi==5.1.0
|
|
57
|
-
Requires-Dist: eth-account==0.13.4
|
|
58
|
-
Requires-Dist: eth-hash==0.7.0
|
|
59
|
-
Requires-Dist: eth-keyfile==0.8.1
|
|
60
|
-
Requires-Dist: eth-keys==0.5.1
|
|
61
|
-
Requires-Dist: eth-rlp==2.1.0
|
|
62
|
-
Requires-Dist: eth-typing==5.0.0
|
|
63
|
-
Requires-Dist: eth-utils==5.0.0
|
|
64
|
-
Requires-Dist: fastjsonschema==2.20.0
|
|
65
|
-
Requires-Dist: fastparquet==2024.5.0
|
|
66
|
-
Requires-Dist: filelock==3.16.1
|
|
67
|
-
Requires-Dist: firebase-rest-api==1.11.0
|
|
68
|
-
Requires-Dist: frozenlist==1.4.1
|
|
69
|
-
Requires-Dist: fsspec==2024.9.0
|
|
70
|
-
Requires-Dist: google-api-core==2.20.0
|
|
71
|
-
Requires-Dist: google-auth==2.35.0
|
|
72
|
-
Requires-Dist: google-cloud-core==2.4.1
|
|
73
|
-
Requires-Dist: google-cloud-firestore==2.19.0
|
|
74
|
-
Requires-Dist: google-cloud-storage==2.18.2
|
|
75
|
-
Requires-Dist: google-crc32c==1.6.0
|
|
76
|
-
Requires-Dist: google-resumable-media==2.7.2
|
|
77
|
-
Requires-Dist: googleapis-common-protos==1.65.0
|
|
78
|
-
Requires-Dist: grpcio-tools==1.66.2
|
|
79
|
-
Requires-Dist: grpcio==1.66.2
|
|
80
|
-
Requires-Dist: hexbytes==1.2.1
|
|
81
|
-
Requires-Dist: idna==3.10
|
|
82
|
-
Requires-Dist: jaraco-classes==3.4.0
|
|
83
|
-
Requires-Dist: jwcrypto==1.5.6
|
|
84
|
-
Requires-Dist: keyring==24.3.1
|
|
85
|
-
Requires-Dist: langchain==0.3.7
|
|
86
|
-
Requires-Dist: more-itertools==10.5.0
|
|
87
|
-
Requires-Dist: msgpack==1.1.0
|
|
88
|
-
Requires-Dist: multidict==6.1.0
|
|
89
|
-
Requires-Dist: openai==1.58.1
|
|
90
|
-
Requires-Dist: packaging==24.1
|
|
91
|
-
Requires-Dist: pandas==2.2.3
|
|
92
|
-
Requires-Dist: parsimonious==0.10.0
|
|
93
|
-
Requires-Dist: pathlib==1.0.1
|
|
94
|
-
Requires-Dist: pexpect==4.9.0
|
|
95
|
-
Requires-Dist: pkce==1.0.3
|
|
96
|
-
Requires-Dist: pkginfo==1.11.1
|
|
97
|
-
Requires-Dist: platformdirs==4.3.6
|
|
98
|
-
Requires-Dist: proto-plus==1.24.0
|
|
99
|
-
Requires-Dist: protobuf==5.28.2
|
|
100
|
-
Requires-Dist: protobuf>=4.24.0
|
|
101
|
-
Requires-Dist: ptyprocess==0.7.0
|
|
102
|
-
Requires-Dist: pyarrow==17.0.0
|
|
103
|
-
Requires-Dist: pyasn1-modules==0.4.1
|
|
104
|
-
Requires-Dist: pyasn1==0.6.1
|
|
105
|
-
Requires-Dist: pycparser==2.22
|
|
106
|
-
Requires-Dist: pycryptodome==3.21.0
|
|
107
|
-
Requires-Dist: pydantic-core==2.23.4
|
|
108
|
-
Requires-Dist: pydantic==2.9.2
|
|
109
|
-
Requires-Dist: pyproject-hooks==1.2.0
|
|
110
|
-
Requires-Dist: python-dateutil==2.9.0.post0
|
|
111
|
-
Requires-Dist: python-jwt==4.1.0
|
|
112
|
-
Requires-Dist: pytz==2024.2
|
|
113
|
-
Requires-Dist: pyunormalize==16.0.0
|
|
114
|
-
Requires-Dist: rapidfuzz==3.10.0
|
|
115
|
-
Requires-Dist: regex==2024.9.11
|
|
116
|
-
Requires-Dist: requests-toolbelt==1.0.0
|
|
117
|
-
Requires-Dist: requests==2.32.3
|
|
118
|
-
Requires-Dist: rlp==4.0.1
|
|
119
|
-
Requires-Dist: rsa==4.9
|
|
120
|
-
Requires-Dist: shellingham==1.5.4
|
|
121
|
-
Requires-Dist: six==1.16.0
|
|
122
|
-
Requires-Dist: tomlkit==0.13.2
|
|
123
|
-
Requires-Dist: toolz==0.12.1
|
|
124
|
-
Requires-Dist: trove-classifiers==2024.9.12
|
|
125
|
-
Requires-Dist: types-requests==2.32.0.20240914
|
|
126
|
-
Requires-Dist: typing-extensions==4.12.2
|
|
127
|
-
Requires-Dist: tzdata==2024.2
|
|
128
|
-
Requires-Dist: urllib3==2.2.3
|
|
129
|
-
Requires-Dist: web3==7.3.0
|
|
130
|
-
Requires-Dist: websockets==13.1
|
|
131
|
-
Requires-Dist: xattr==1.1.0
|
|
132
|
-
Requires-Dist: yarl==1.13.1
|
|
133
36
|
Description-Content-Type: text/markdown
|
|
37
|
+
License-File: LICENSE
|
|
38
|
+
Requires-Dist: aiohappyeyeballs>=2.4.3
|
|
39
|
+
Requires-Dist: aiohttp>=3.10.8
|
|
40
|
+
Requires-Dist: aiosignal>=1.3.1
|
|
41
|
+
Requires-Dist: annotated-types>=0.7.0
|
|
42
|
+
Requires-Dist: attrs>=24.2.0
|
|
43
|
+
Requires-Dist: bitarray>=2.9.2
|
|
44
|
+
Requires-Dist: CacheControl>=0.14.0
|
|
45
|
+
Requires-Dist: cachetools>=5.5.0
|
|
46
|
+
Requires-Dist: certifi>=2024.8.30
|
|
47
|
+
Requires-Dist: cffi>=1.17.1
|
|
48
|
+
Requires-Dist: charset-normalizer>=3.3.2
|
|
49
|
+
Requires-Dist: ckzg>=2.0.1
|
|
50
|
+
Requires-Dist: cleo>=2.1.0
|
|
51
|
+
Requires-Dist: click>=8.1.7
|
|
52
|
+
Requires-Dist: cramjam>=2.8.4
|
|
53
|
+
Requires-Dist: crashtest>=0.4.1
|
|
54
|
+
Requires-Dist: cryptography>=43.0.1
|
|
55
|
+
Requires-Dist: cytoolz>=0.12.3
|
|
56
|
+
Requires-Dist: distlib>=0.3.8
|
|
57
|
+
Requires-Dist: dulwich>=0.21.7
|
|
58
|
+
Requires-Dist: eth-account>=0.13.4
|
|
59
|
+
Requires-Dist: eth-hash>=0.7.0
|
|
60
|
+
Requires-Dist: eth-keyfile>=0.8.1
|
|
61
|
+
Requires-Dist: eth-keys>=0.5.1
|
|
62
|
+
Requires-Dist: eth-rlp>=2.1.0
|
|
63
|
+
Requires-Dist: eth-typing>=5.0.0
|
|
64
|
+
Requires-Dist: eth-utils>=5.0.0
|
|
65
|
+
Requires-Dist: eth_abi>=5.1.0
|
|
66
|
+
Requires-Dist: fastjsonschema>=2.20.0
|
|
67
|
+
Requires-Dist: fastparquet>=2024.5.0
|
|
68
|
+
Requires-Dist: filelock>=3.16.1
|
|
69
|
+
Requires-Dist: firebase-rest-api>=1.11.0
|
|
70
|
+
Requires-Dist: frozenlist>=1.4.1
|
|
71
|
+
Requires-Dist: fsspec>=2024.9.0
|
|
72
|
+
Requires-Dist: google-api-core>=2.20.0
|
|
73
|
+
Requires-Dist: google-auth>=2.35.0
|
|
74
|
+
Requires-Dist: google-cloud-core>=2.4.1
|
|
75
|
+
Requires-Dist: google-cloud-firestore>=2.19.0
|
|
76
|
+
Requires-Dist: google-cloud-storage>=2.18.2
|
|
77
|
+
Requires-Dist: google-crc32c>=1.6.0
|
|
78
|
+
Requires-Dist: google-resumable-media>=2.7.2
|
|
79
|
+
Requires-Dist: googleapis-common-protos>=1.65.0
|
|
80
|
+
Requires-Dist: grpcio>=1.66.2
|
|
81
|
+
Requires-Dist: grpcio-tools>=1.66.2
|
|
82
|
+
Requires-Dist: protobuf>=4.24.0
|
|
83
|
+
Requires-Dist: hexbytes>=1.2.1
|
|
84
|
+
Requires-Dist: idna>=3.10
|
|
85
|
+
Requires-Dist: jaraco.classes>=3.4.0
|
|
86
|
+
Requires-Dist: jwcrypto>=1.5.6
|
|
87
|
+
Requires-Dist: keyring>=24.3.1
|
|
88
|
+
Requires-Dist: langchain>=0.3.7
|
|
89
|
+
Requires-Dist: more-itertools>=10.5.0
|
|
90
|
+
Requires-Dist: msgpack>=1.1.0
|
|
91
|
+
Requires-Dist: multidict>=6.1.0
|
|
92
|
+
Requires-Dist: openai>=1.58.1
|
|
93
|
+
Requires-Dist: packaging>=24.1
|
|
94
|
+
Requires-Dist: pandas>=2.2.3
|
|
95
|
+
Requires-Dist: parsimonious>=0.10.0
|
|
96
|
+
Requires-Dist: pathlib>=1.0.1
|
|
97
|
+
Requires-Dist: pexpect>=4.9.0
|
|
98
|
+
Requires-Dist: pkce>=1.0.3
|
|
99
|
+
Requires-Dist: pkginfo>=1.11.1
|
|
100
|
+
Requires-Dist: platformdirs>=4.3.6
|
|
101
|
+
Requires-Dist: proto-plus>=1.24.0
|
|
102
|
+
Requires-Dist: protobuf>=5.28.2
|
|
103
|
+
Requires-Dist: ptyprocess>=0.7.0
|
|
104
|
+
Requires-Dist: pyarrow>=17.0.0
|
|
105
|
+
Requires-Dist: pyasn1>=0.6.1
|
|
106
|
+
Requires-Dist: pyasn1_modules>=0.4.1
|
|
107
|
+
Requires-Dist: pycparser>=2.22
|
|
108
|
+
Requires-Dist: pycryptodome>=3.21.0
|
|
109
|
+
Requires-Dist: pydantic>=2.9.2
|
|
110
|
+
Requires-Dist: pydantic_core>=2.23.4
|
|
111
|
+
Requires-Dist: pyproject_hooks>=1.2.0
|
|
112
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
113
|
+
Requires-Dist: python-jwt>=4.1.0
|
|
114
|
+
Requires-Dist: pytz>=2024.2
|
|
115
|
+
Requires-Dist: pyunormalize>=16.0.0
|
|
116
|
+
Requires-Dist: RapidFuzz>=3.10.0
|
|
117
|
+
Requires-Dist: regex>=2024.9.11
|
|
118
|
+
Requires-Dist: requests>=2.32.3
|
|
119
|
+
Requires-Dist: requests-toolbelt>=1.0.0
|
|
120
|
+
Requires-Dist: rlp>=4.0.1
|
|
121
|
+
Requires-Dist: rsa>=4.9
|
|
122
|
+
Requires-Dist: shellingham>=1.5.4
|
|
123
|
+
Requires-Dist: six>=1.16.0
|
|
124
|
+
Requires-Dist: tomlkit>=0.13.2
|
|
125
|
+
Requires-Dist: toolz>=0.12.1
|
|
126
|
+
Requires-Dist: trove-classifiers>=2024.9.12
|
|
127
|
+
Requires-Dist: types-requests>=2.32.0.20240914
|
|
128
|
+
Requires-Dist: typing_extensions>=4.12.2
|
|
129
|
+
Requires-Dist: tzdata>=2024.2
|
|
130
|
+
Requires-Dist: urllib3>=2.2.3
|
|
131
|
+
Requires-Dist: web3>=7.3.0
|
|
132
|
+
Requires-Dist: websockets>=13.1
|
|
133
|
+
Requires-Dist: xattr>=1.1.0
|
|
134
|
+
Requires-Dist: yarl>=1.13.1
|
|
134
135
|
|
|
135
136
|
# OpenGradient Python SDK
|
|
136
137
|
Python SDK for the OpenGradient platform provides decentralized model management & inference services. Python SDK allows programmatic access to our model repository and decentralized AI infrastructure.
|
|
@@ -272,4 +273,4 @@ Or you can use files instead of text input in order to simplify your command:
|
|
|
272
273
|
opengradient chat --model "mistralai/Mistral-7B-Instruct-v0.3" --messages-file messages.json --tools-file tools.json --max-tokens 200
|
|
273
274
|
```
|
|
274
275
|
|
|
275
|
-
For more information read the OpenGradient [documentation](https://docs.opengradient.ai/).
|
|
276
|
+
For more information read the OpenGradient [documentation](https://docs.opengradient.ai/).
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "opengradient"
|
|
7
|
+
version = "0.3.21"
|
|
8
|
+
description = "Python SDK for OpenGradient decentralized model management & inference services"
|
|
9
|
+
authors = [{name = "OpenGradient", email = "oliver@opengradient.ai"}]
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
]
|
|
21
|
+
# Dependencies kept as is...
|
|
22
|
+
dependencies = [
|
|
23
|
+
"aiohappyeyeballs>=2.4.3",
|
|
24
|
+
"aiohttp>=3.10.8",
|
|
25
|
+
"aiosignal>=1.3.1",
|
|
26
|
+
"annotated-types>=0.7.0",
|
|
27
|
+
"attrs>=24.2.0",
|
|
28
|
+
"bitarray>=2.9.2",
|
|
29
|
+
"CacheControl>=0.14.0",
|
|
30
|
+
"cachetools>=5.5.0",
|
|
31
|
+
"certifi>=2024.8.30",
|
|
32
|
+
"cffi>=1.17.1",
|
|
33
|
+
"charset-normalizer>=3.3.2",
|
|
34
|
+
"ckzg>=2.0.1",
|
|
35
|
+
"cleo>=2.1.0",
|
|
36
|
+
"click>=8.1.7",
|
|
37
|
+
"cramjam>=2.8.4",
|
|
38
|
+
"crashtest>=0.4.1",
|
|
39
|
+
"cryptography>=43.0.1",
|
|
40
|
+
"cytoolz>=0.12.3",
|
|
41
|
+
"distlib>=0.3.8",
|
|
42
|
+
"dulwich>=0.21.7",
|
|
43
|
+
"eth-account>=0.13.4",
|
|
44
|
+
"eth-hash>=0.7.0",
|
|
45
|
+
"eth-keyfile>=0.8.1",
|
|
46
|
+
"eth-keys>=0.5.1",
|
|
47
|
+
"eth-rlp>=2.1.0",
|
|
48
|
+
"eth-typing>=5.0.0",
|
|
49
|
+
"eth-utils>=5.0.0",
|
|
50
|
+
"eth_abi>=5.1.0",
|
|
51
|
+
"fastjsonschema>=2.20.0",
|
|
52
|
+
"fastparquet>=2024.5.0",
|
|
53
|
+
"filelock>=3.16.1",
|
|
54
|
+
"firebase-rest-api>=1.11.0",
|
|
55
|
+
"frozenlist>=1.4.1",
|
|
56
|
+
"fsspec>=2024.9.0",
|
|
57
|
+
"google-api-core>=2.20.0",
|
|
58
|
+
"google-auth>=2.35.0",
|
|
59
|
+
"google-cloud-core>=2.4.1",
|
|
60
|
+
"google-cloud-firestore>=2.19.0",
|
|
61
|
+
"google-cloud-storage>=2.18.2",
|
|
62
|
+
"google-crc32c>=1.6.0",
|
|
63
|
+
"google-resumable-media>=2.7.2",
|
|
64
|
+
"googleapis-common-protos>=1.65.0",
|
|
65
|
+
"grpcio>=1.66.2",
|
|
66
|
+
"grpcio-tools>=1.66.2",
|
|
67
|
+
"protobuf>=4.24.0",
|
|
68
|
+
"hexbytes>=1.2.1",
|
|
69
|
+
"idna>=3.10",
|
|
70
|
+
"jaraco.classes>=3.4.0",
|
|
71
|
+
"jwcrypto>=1.5.6",
|
|
72
|
+
"keyring>=24.3.1",
|
|
73
|
+
"langchain>=0.3.7",
|
|
74
|
+
"more-itertools>=10.5.0",
|
|
75
|
+
"msgpack>=1.1.0",
|
|
76
|
+
"multidict>=6.1.0",
|
|
77
|
+
"openai>=1.58.1",
|
|
78
|
+
"packaging>=24.1",
|
|
79
|
+
"pandas>=2.2.3",
|
|
80
|
+
"parsimonious>=0.10.0",
|
|
81
|
+
"pathlib>=1.0.1",
|
|
82
|
+
"pexpect>=4.9.0",
|
|
83
|
+
"pkce>=1.0.3",
|
|
84
|
+
"pkginfo>=1.11.1",
|
|
85
|
+
"platformdirs>=4.3.6",
|
|
86
|
+
"proto-plus>=1.24.0",
|
|
87
|
+
"protobuf>=5.28.2",
|
|
88
|
+
"ptyprocess>=0.7.0",
|
|
89
|
+
"pyarrow>=17.0.0",
|
|
90
|
+
"pyasn1>=0.6.1",
|
|
91
|
+
"pyasn1_modules>=0.4.1",
|
|
92
|
+
"pycparser>=2.22",
|
|
93
|
+
"pycryptodome>=3.21.0",
|
|
94
|
+
"pydantic>=2.9.2",
|
|
95
|
+
"pydantic_core>=2.23.4",
|
|
96
|
+
"pyproject_hooks>=1.2.0",
|
|
97
|
+
"python-dateutil>=2.9.0.post0",
|
|
98
|
+
"python-jwt>=4.1.0",
|
|
99
|
+
"pytz>=2024.2",
|
|
100
|
+
"pyunormalize>=16.0.0",
|
|
101
|
+
"RapidFuzz>=3.10.0",
|
|
102
|
+
"regex>=2024.9.11",
|
|
103
|
+
"requests>=2.32.3",
|
|
104
|
+
"requests-toolbelt>=1.0.0",
|
|
105
|
+
"rlp>=4.0.1",
|
|
106
|
+
"rsa>=4.9",
|
|
107
|
+
"shellingham>=1.5.4",
|
|
108
|
+
"six>=1.16.0",
|
|
109
|
+
"tomlkit>=0.13.2",
|
|
110
|
+
"toolz>=0.12.1",
|
|
111
|
+
"trove-classifiers>=2024.9.12",
|
|
112
|
+
"types-requests>=2.32.0.20240914",
|
|
113
|
+
"typing_extensions>=4.12.2",
|
|
114
|
+
"tzdata>=2024.2",
|
|
115
|
+
"urllib3>=2.2.3",
|
|
116
|
+
"web3>=7.3.0",
|
|
117
|
+
"websockets>=13.1",
|
|
118
|
+
"xattr>=1.1.0",
|
|
119
|
+
"yarl>=1.13.1",
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[project.scripts]
|
|
123
|
+
opengradient = "opengradient.cli:cli"
|
|
124
|
+
|
|
125
|
+
[project.urls]
|
|
126
|
+
Homepage = "https://opengradient.ai"
|
|
127
|
+
|
|
128
|
+
[tool.setuptools]
|
|
129
|
+
package-dir = {"" = "src"}
|
|
130
|
+
include-package-data = true
|
|
131
|
+
|
|
132
|
+
[tool.setuptools.packages.find]
|
|
133
|
+
where = ["src"]
|
|
134
|
+
include = ["opengradient*"] # Explicitly include all opengradient packages
|
|
135
|
+
exclude = ["tests*", "stresstest*"]
|
|
136
|
+
|
|
137
|
+
[tool.setuptools.package-data]
|
|
138
|
+
"opengradient" = [
|
|
139
|
+
"abi/*.abi",
|
|
140
|
+
"proto/*.proto",
|
|
141
|
+
"**/*.py"
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
[tool.ruff]
|
|
145
|
+
line-length = 140
|
|
146
|
+
target-version = "py310"
|
|
147
|
+
select = ["E", "F", "I", "N"]
|
|
148
|
+
ignore = []
|
|
149
|
+
|
|
150
|
+
[tool.ruff.mccabe]
|
|
151
|
+
max-complexity = 10
|
|
@@ -7,9 +7,9 @@ from typing import Dict, List, Optional, Tuple
|
|
|
7
7
|
from .client import Client
|
|
8
8
|
from .defaults import DEFAULT_INFERENCE_CONTRACT_ADDRESS, DEFAULT_RPC_URL
|
|
9
9
|
from .types import InferenceMode, LlmInferenceMode, LLM, TEE_LLM
|
|
10
|
-
from . import llm
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
from . import llm
|
|
12
|
+
from . import mltools
|
|
13
13
|
|
|
14
14
|
_client = None
|
|
15
15
|
|
|
@@ -241,7 +241,7 @@ def generate_image(model: str, prompt: str, height: Optional[int] = None, width:
|
|
|
241
241
|
|
|
242
242
|
__all__ = [
|
|
243
243
|
'generate_image',
|
|
244
|
-
'list_files'
|
|
244
|
+
'list_files',
|
|
245
245
|
'login',
|
|
246
246
|
'llm_chat',
|
|
247
247
|
'llm_completion',
|
|
@@ -261,6 +261,7 @@ __pdoc__ = {
|
|
|
261
261
|
'defaults': False,
|
|
262
262
|
'exceptions': False,
|
|
263
263
|
'llm': True,
|
|
264
|
+
'mltools': True,
|
|
264
265
|
'proto': False,
|
|
265
266
|
'types': False,
|
|
266
267
|
'utils': False
|
|
@@ -17,7 +17,7 @@ from langchain_core.callbacks.manager import CallbackManagerForLLMRun
|
|
|
17
17
|
from langchain_core.tools import BaseTool
|
|
18
18
|
from langchain_core.messages import ToolCall
|
|
19
19
|
|
|
20
|
-
from opengradient import Client
|
|
20
|
+
from opengradient import Client, LlmInferenceMode
|
|
21
21
|
from opengradient.defaults import DEFAULT_RPC_URL, DEFAULT_INFERENCE_CONTRACT_ADDRESS
|
|
22
22
|
|
|
23
23
|
|
|
@@ -99,7 +99,8 @@ class OpenGradientChatModel(BaseChatModel):
|
|
|
99
99
|
messages=sdk_messages,
|
|
100
100
|
stop_sequence=stop,
|
|
101
101
|
max_tokens=self.max_tokens,
|
|
102
|
-
tools=self.tools
|
|
102
|
+
tools=self.tools,
|
|
103
|
+
inference_mode=LlmInferenceMode.VANILLA
|
|
103
104
|
)
|
|
104
105
|
|
|
105
106
|
if "tool_calls" in chat_response and chat_response["tool_calls"]:
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Callable, Dict, Any, Type
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
from langchain_core.tools import BaseTool, StructuredTool
|
|
6
|
+
import opengradient as og
|
|
7
|
+
|
|
8
|
+
class ToolType(str, Enum):
|
|
9
|
+
"""Indicates the framework the tool is compatible with."""
|
|
10
|
+
|
|
11
|
+
LANGCHAIN = "langchain"
|
|
12
|
+
SWARM = "swarm"
|
|
13
|
+
|
|
14
|
+
def __str__(self) -> str:
|
|
15
|
+
return self.value
|
|
16
|
+
|
|
17
|
+
def create_og_model_tool(
|
|
18
|
+
tool_type: ToolType,
|
|
19
|
+
model_cid: str,
|
|
20
|
+
tool_name: str,
|
|
21
|
+
input_getter: Callable,
|
|
22
|
+
output_formatter: Callable[..., str],
|
|
23
|
+
input_schema: Type[BaseModel] = None,
|
|
24
|
+
tool_description: str = "Executes the given ML model",
|
|
25
|
+
inference_mode: og.InferenceMode= og.InferenceMode.VANILLA) -> BaseTool:
|
|
26
|
+
"""
|
|
27
|
+
Creates a tool that wraps an OpenGradient model for inference.
|
|
28
|
+
|
|
29
|
+
This function generates a tool that can be integrated into either a LangChain pipeline
|
|
30
|
+
or a Swarm system, allowing the model to be executed as part of a chain of operations.
|
|
31
|
+
The tool uses the provided input_getter function to obtain the necessary input data and
|
|
32
|
+
runs inference using the specified OpenGradient model.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
tool_type (ToolType): Specifies the framework to create the tool for. Use
|
|
36
|
+
ToolType.LANGCHAIN for LangChain integration or ToolType.SWARM for Swarm
|
|
37
|
+
integration.
|
|
38
|
+
model_cid (str): The CID of the OpenGradient model to be executed.
|
|
39
|
+
tool_name (str): The name to assign to the created tool. This will be used to identify
|
|
40
|
+
and invoke the tool within the agent.
|
|
41
|
+
input_getter (Callable): A function that returns the input data required by the model.
|
|
42
|
+
The function should return data in a format compatible with the model's expectations.
|
|
43
|
+
output_formatter (Callable[..., str]): A function that takes the model output and
|
|
44
|
+
formats it into a string. This is required to ensure the output is compatible
|
|
45
|
+
with the tool framework.
|
|
46
|
+
input_schema (Type[BaseModel], optional): A Pydantic BaseModel class defining the
|
|
47
|
+
input schema. This will be used directly for LangChain tools and converted
|
|
48
|
+
to appropriate annotations for Swarm tools. Default is None.
|
|
49
|
+
tool_description (str, optional): A description of what the tool does. Defaults to
|
|
50
|
+
"Executes the given ML model".
|
|
51
|
+
inference_mode (og.InferenceMode, optional): The inference mode to use when running
|
|
52
|
+
the model. Defaults to VANILLA.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
BaseTool: For ToolType.LANGCHAIN, returns a LangChain StructuredTool.
|
|
56
|
+
Callable: For ToolType.SWARM, returns a decorated function with appropriate metadata.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ValueError: If an invalid tool_type is provided.
|
|
60
|
+
|
|
61
|
+
Examples:
|
|
62
|
+
>>> from pydantic import BaseModel, Field
|
|
63
|
+
>>> class ClassifierInput(BaseModel):
|
|
64
|
+
... query: str = Field(description="User query to analyze")
|
|
65
|
+
... parameters: dict = Field(description="Additional parameters")
|
|
66
|
+
>>> def get_input():
|
|
67
|
+
... return {"text": "Sample input text"}
|
|
68
|
+
>>> def format_output(output):
|
|
69
|
+
... return str(output.get("class", "Unknown"))
|
|
70
|
+
>>> # Create a LangChain tool
|
|
71
|
+
>>> langchain_tool = create_og_model_tool(
|
|
72
|
+
... tool_type=ToolType.LANGCHAIN,
|
|
73
|
+
... model_cid="Qm...",
|
|
74
|
+
... tool_name="text_classifier",
|
|
75
|
+
... input_getter=get_input,
|
|
76
|
+
... output_formatter=format_output,
|
|
77
|
+
... input_schema=ClassifierInput
|
|
78
|
+
... tool_description="Classifies text into categories"
|
|
79
|
+
... )
|
|
80
|
+
"""
|
|
81
|
+
# define runnable
|
|
82
|
+
def model_executor(**llm_input):
|
|
83
|
+
# Combine LLM input with input provided by code
|
|
84
|
+
combined_input = {
|
|
85
|
+
**llm_input,
|
|
86
|
+
**input_getter()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_, output = og.infer(
|
|
90
|
+
model_cid=model_cid,
|
|
91
|
+
inference_mode=inference_mode,
|
|
92
|
+
model_input=combined_input
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return output_formatter(output)
|
|
96
|
+
|
|
97
|
+
if tool_type == ToolType.LANGCHAIN:
|
|
98
|
+
return StructuredTool.from_function(
|
|
99
|
+
func=model_executor,
|
|
100
|
+
name=tool_name,
|
|
101
|
+
description=tool_description,
|
|
102
|
+
args_schema=input_schema
|
|
103
|
+
)
|
|
104
|
+
elif tool_type == ToolType.SWARM:
|
|
105
|
+
model_executor.__name__ = tool_name
|
|
106
|
+
model_executor.__doc__ = tool_description
|
|
107
|
+
# Convert Pydantic model to Swarm annotations if provided
|
|
108
|
+
if input_schema:
|
|
109
|
+
model_executor.__annotations__ = _convert_pydantic_to_annotations(input_schema)
|
|
110
|
+
return model_executor
|
|
111
|
+
else:
|
|
112
|
+
raise ValueError(f"Invalid tooltype: {tool_type}")
|
|
113
|
+
|
|
114
|
+
def _convert_pydantic_to_annotations(model: Type[BaseModel]) -> Dict[str, Any]:
|
|
115
|
+
"""
|
|
116
|
+
Convert a Pydantic model to function annotations format used by Swarm.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
model: A Pydantic BaseModel class
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
Dict mapping field names to (type, description) tuples
|
|
123
|
+
"""
|
|
124
|
+
annotations = {}
|
|
125
|
+
for field_name, field in model.model_fields.items():
|
|
126
|
+
field_type = field.annotation
|
|
127
|
+
description = field.description or ""
|
|
128
|
+
annotations[field_name] = (field_type, description)
|
|
129
|
+
return annotations
|