simple-agents-py 0.1.15__tar.gz → 0.2.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.
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/Cargo.lock +126 -12
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/Cargo.toml +4 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/PKG-INFO +29 -7
- {simple_agents_py-0.1.15/crates/simple-agents-py → simple_agents_py-0.2.1}/README.md +28 -6
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-cache/Cargo.toml +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-cache/src/memory.rs +45 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/Cargo.toml +6 -4
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/README.md +21 -4
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/examples/basic_client.rs +10 -2
- simple_agents_py-0.2.1/crates/simple-agents-core/src/client.rs +780 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/src/lib.rs +13 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/src/middleware.rs +9 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/tests/client_integration.rs +49 -7
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/Cargo.toml +2 -2
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/coercion.rs +4 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/parser.rs +3 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-macros/Cargo.toml +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/Cargo.toml +5 -5
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/openai/mod.rs +4 -9
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/openrouter/mod.rs +2 -6
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/Cargo.toml +6 -6
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1/crates/simple-agents-py}/README.md +28 -6
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/client_builder_demo.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/healing_demo.py +6 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/streaming_demo.py +25 -5
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/structured_streaming_demo.py +44 -19
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/simple_agents_py.pyi +8 -67
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/src/lib.rs +462 -623
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_client.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_client_builder.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_direct_healing.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_healing.py +7 -5
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_integration_openai.py +29 -6
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_routing_config.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_streaming.py +7 -7
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_streaming_parser.py +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/tests/test_structured_streaming.py +17 -13
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/uv.lock +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/Cargo.toml +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/fallback.rs +5 -2
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/latency.rs +2 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/pyproject.toml +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/simple_agents_py.pyi +8 -67
- simple_agents_py-0.1.15/crates/simple-agent-type/TODO.md +0 -590
- simple_agents_py-0.1.15/crates/simple-agents-core/src/client.rs +0 -425
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/Cargo.toml +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/README.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/TEST_GUIDE.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/examples/basic_usage.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/examples/mock_provider.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/cache.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/coercion.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/config.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/error.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/message.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/provider.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/request.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/response.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/router.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/tool.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/src/validation.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agent-type/tests/integration_test.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-cache/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-cache/src/noop.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/src/healing.rs +2 -2
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-core/src/routing.rs +3 -3
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/README.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/benches/parser_benchmarks.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/examples/basic_healing.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/examples/coercion_demo.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/examples/streaming_annotations.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/examples/streaming_partial_types.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/schema.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/streaming.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/src/string_utils.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/tests/parser_tests.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/tests/property_tests.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/tests/stream_annotations_tests.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-healing/tests/streaming_tests.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-macros/README.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-macros/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-macros/src/partial.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-macros/tests/partial_type_tests.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/README.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/anthropic_basic.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/anthropic_structured_output.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/cache_usage.rs +2 -2
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/custom_api.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/healing_fallback.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/openai_basic.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/openai_structured_output.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/openrouter_basic.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/retry_demo.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/streaming.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/streaming_structured.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/streaming_with_healing.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/test_local_api.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/examples/test_reqwest.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/run_integration_tests.sh +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/anthropic/error.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/anthropic/mod.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/anthropic/models.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/anthropic/streaming.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/common/error.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/common/http_client.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/common/mod.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/healing_integration.rs +2 -2
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/metrics.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/openai/error.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/openai/models.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/openai/streaming.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/rate_limit.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/retry.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/schema_converter.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/streaming_structured.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/src/utils.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/tests/README.md +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/tests/healing_integration_tests.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-providers/tests/openai_integration.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/direct_healing_demo.py +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/routing_config_demo.py +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/examples/streaming_parser_demo.py +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-py/py.typed +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/examples/round_robin_router.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/circuit_breaker.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/cost.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/health.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/lib.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/retry.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/src/round_robin.rs +0 -0
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/crates/simple-agents-router/tests/health_tracker_integration.rs +1 -1
- {simple_agents_py-0.1.15 → simple_agents_py-0.2.1}/py.typed +0 -0
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
# It is not intended for manual editing.
|
|
3
3
|
version = 3
|
|
4
4
|
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "adler2"
|
|
7
|
+
version = "2.0.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|
10
|
+
|
|
5
11
|
[[package]]
|
|
6
12
|
name = "ahash"
|
|
7
13
|
version = "0.8.12"
|
|
@@ -23,6 +29,21 @@ dependencies = [
|
|
|
23
29
|
"memchr",
|
|
24
30
|
]
|
|
25
31
|
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "alloc-no-stdlib"
|
|
34
|
+
version = "2.0.4"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "alloc-stdlib"
|
|
40
|
+
version = "0.2.2"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"alloc-no-stdlib",
|
|
45
|
+
]
|
|
46
|
+
|
|
26
47
|
[[package]]
|
|
27
48
|
name = "anes"
|
|
28
49
|
version = "0.1.6"
|
|
@@ -91,6 +112,18 @@ version = "0.7.6"
|
|
|
91
112
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
92
113
|
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
|
93
114
|
|
|
115
|
+
[[package]]
|
|
116
|
+
name = "async-compression"
|
|
117
|
+
version = "0.4.37"
|
|
118
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
+
checksum = "d10e4f991a553474232bc0a31799f6d24b034a84c0971d80d2e2f78b2e576e40"
|
|
120
|
+
dependencies = [
|
|
121
|
+
"compression-codecs",
|
|
122
|
+
"compression-core",
|
|
123
|
+
"pin-project-lite",
|
|
124
|
+
"tokio",
|
|
125
|
+
]
|
|
126
|
+
|
|
94
127
|
[[package]]
|
|
95
128
|
name = "async-trait"
|
|
96
129
|
version = "0.1.89"
|
|
@@ -177,6 +210,27 @@ dependencies = [
|
|
|
177
210
|
"cpufeatures",
|
|
178
211
|
]
|
|
179
212
|
|
|
213
|
+
[[package]]
|
|
214
|
+
name = "brotli"
|
|
215
|
+
version = "8.0.2"
|
|
216
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
217
|
+
checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560"
|
|
218
|
+
dependencies = [
|
|
219
|
+
"alloc-no-stdlib",
|
|
220
|
+
"alloc-stdlib",
|
|
221
|
+
"brotli-decompressor",
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
[[package]]
|
|
225
|
+
name = "brotli-decompressor"
|
|
226
|
+
version = "5.0.0"
|
|
227
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
228
|
+
checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03"
|
|
229
|
+
dependencies = [
|
|
230
|
+
"alloc-no-stdlib",
|
|
231
|
+
"alloc-stdlib",
|
|
232
|
+
]
|
|
233
|
+
|
|
180
234
|
[[package]]
|
|
181
235
|
name = "bumpalo"
|
|
182
236
|
version = "3.19.1"
|
|
@@ -295,6 +349,24 @@ version = "1.0.4"
|
|
|
295
349
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
296
350
|
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
|
297
351
|
|
|
352
|
+
[[package]]
|
|
353
|
+
name = "compression-codecs"
|
|
354
|
+
version = "0.4.36"
|
|
355
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
356
|
+
checksum = "00828ba6fd27b45a448e57dbfe84f1029d4c9f26b368157e9a448a5f49a2ec2a"
|
|
357
|
+
dependencies = [
|
|
358
|
+
"brotli",
|
|
359
|
+
"compression-core",
|
|
360
|
+
"flate2",
|
|
361
|
+
"memchr",
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
[[package]]
|
|
365
|
+
name = "compression-core"
|
|
366
|
+
version = "0.4.31"
|
|
367
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
368
|
+
checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d"
|
|
369
|
+
|
|
298
370
|
[[package]]
|
|
299
371
|
name = "constant_time_eq"
|
|
300
372
|
version = "0.4.2"
|
|
@@ -345,6 +417,15 @@ dependencies = [
|
|
|
345
417
|
"libc",
|
|
346
418
|
]
|
|
347
419
|
|
|
420
|
+
[[package]]
|
|
421
|
+
name = "crc32fast"
|
|
422
|
+
version = "1.5.0"
|
|
423
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
424
|
+
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
|
425
|
+
dependencies = [
|
|
426
|
+
"cfg-if",
|
|
427
|
+
]
|
|
428
|
+
|
|
348
429
|
[[package]]
|
|
349
430
|
name = "criterion"
|
|
350
431
|
version = "0.5.1"
|
|
@@ -501,6 +582,16 @@ version = "0.1.8"
|
|
|
501
582
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
502
583
|
checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
|
|
503
584
|
|
|
585
|
+
[[package]]
|
|
586
|
+
name = "flate2"
|
|
587
|
+
version = "1.1.8"
|
|
588
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
589
|
+
checksum = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369"
|
|
590
|
+
dependencies = [
|
|
591
|
+
"crc32fast",
|
|
592
|
+
"miniz_oxide",
|
|
593
|
+
]
|
|
594
|
+
|
|
504
595
|
[[package]]
|
|
505
596
|
name = "fnv"
|
|
506
597
|
version = "1.0.7"
|
|
@@ -1165,6 +1256,16 @@ version = "0.3.17"
|
|
|
1165
1256
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1166
1257
|
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
|
1167
1258
|
|
|
1259
|
+
[[package]]
|
|
1260
|
+
name = "miniz_oxide"
|
|
1261
|
+
version = "0.8.9"
|
|
1262
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1263
|
+
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
|
1264
|
+
dependencies = [
|
|
1265
|
+
"adler2",
|
|
1266
|
+
"simd-adler32",
|
|
1267
|
+
]
|
|
1268
|
+
|
|
1168
1269
|
[[package]]
|
|
1169
1270
|
name = "mio"
|
|
1170
1271
|
version = "1.1.1"
|
|
@@ -2033,9 +2134,15 @@ dependencies = [
|
|
|
2033
2134
|
"libc",
|
|
2034
2135
|
]
|
|
2035
2136
|
|
|
2137
|
+
[[package]]
|
|
2138
|
+
name = "simd-adler32"
|
|
2139
|
+
version = "0.3.8"
|
|
2140
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2141
|
+
checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2"
|
|
2142
|
+
|
|
2036
2143
|
[[package]]
|
|
2037
2144
|
name = "simple-agent-type"
|
|
2038
|
-
version = "0.1
|
|
2145
|
+
version = "0.2.1"
|
|
2039
2146
|
dependencies = [
|
|
2040
2147
|
"async-trait",
|
|
2041
2148
|
"blake3",
|
|
@@ -2050,7 +2157,7 @@ dependencies = [
|
|
|
2050
2157
|
|
|
2051
2158
|
[[package]]
|
|
2052
2159
|
name = "simple-agents-cache"
|
|
2053
|
-
version = "0.1
|
|
2160
|
+
version = "0.2.1"
|
|
2054
2161
|
dependencies = [
|
|
2055
2162
|
"async-trait",
|
|
2056
2163
|
"simple-agent-type",
|
|
@@ -2059,7 +2166,7 @@ dependencies = [
|
|
|
2059
2166
|
|
|
2060
2167
|
[[package]]
|
|
2061
2168
|
name = "simple-agents-cli"
|
|
2062
|
-
version = "0.1
|
|
2169
|
+
version = "0.2.1"
|
|
2063
2170
|
dependencies = [
|
|
2064
2171
|
"clap",
|
|
2065
2172
|
"serde",
|
|
@@ -2076,10 +2183,11 @@ dependencies = [
|
|
|
2076
2183
|
|
|
2077
2184
|
[[package]]
|
|
2078
2185
|
name = "simple-agents-core"
|
|
2079
|
-
version = "0.1
|
|
2186
|
+
version = "0.2.1"
|
|
2080
2187
|
dependencies = [
|
|
2081
2188
|
"async-trait",
|
|
2082
2189
|
"futures-core",
|
|
2190
|
+
"futures-util",
|
|
2083
2191
|
"serde",
|
|
2084
2192
|
"serde_json",
|
|
2085
2193
|
"simple-agent-type",
|
|
@@ -2087,11 +2195,12 @@ dependencies = [
|
|
|
2087
2195
|
"simple-agents-healing",
|
|
2088
2196
|
"simple-agents-router",
|
|
2089
2197
|
"tokio",
|
|
2198
|
+
"tracing",
|
|
2090
2199
|
]
|
|
2091
2200
|
|
|
2092
2201
|
[[package]]
|
|
2093
2202
|
name = "simple-agents-examples"
|
|
2094
|
-
version = "0.1
|
|
2203
|
+
version = "0.2.1"
|
|
2095
2204
|
dependencies = [
|
|
2096
2205
|
"dotenv",
|
|
2097
2206
|
"futures-util",
|
|
@@ -2104,7 +2213,7 @@ dependencies = [
|
|
|
2104
2213
|
|
|
2105
2214
|
[[package]]
|
|
2106
2215
|
name = "simple-agents-ffi"
|
|
2107
|
-
version = "0.1
|
|
2216
|
+
version = "0.2.1"
|
|
2108
2217
|
dependencies = [
|
|
2109
2218
|
"async-trait",
|
|
2110
2219
|
"simple-agent-type",
|
|
@@ -2115,7 +2224,7 @@ dependencies = [
|
|
|
2115
2224
|
|
|
2116
2225
|
[[package]]
|
|
2117
2226
|
name = "simple-agents-healing"
|
|
2118
|
-
version = "0.1
|
|
2227
|
+
version = "0.2.1"
|
|
2119
2228
|
dependencies = [
|
|
2120
2229
|
"criterion",
|
|
2121
2230
|
"proptest",
|
|
@@ -2131,7 +2240,7 @@ dependencies = [
|
|
|
2131
2240
|
|
|
2132
2241
|
[[package]]
|
|
2133
2242
|
name = "simple-agents-macros"
|
|
2134
|
-
version = "0.1
|
|
2243
|
+
version = "0.2.1"
|
|
2135
2244
|
dependencies = [
|
|
2136
2245
|
"proc-macro2",
|
|
2137
2246
|
"quote",
|
|
@@ -2143,7 +2252,7 @@ dependencies = [
|
|
|
2143
2252
|
|
|
2144
2253
|
[[package]]
|
|
2145
2254
|
name = "simple-agents-napi"
|
|
2146
|
-
version = "0.1
|
|
2255
|
+
version = "0.2.1"
|
|
2147
2256
|
dependencies = [
|
|
2148
2257
|
"napi",
|
|
2149
2258
|
"napi-derive",
|
|
@@ -2155,7 +2264,7 @@ dependencies = [
|
|
|
2155
2264
|
|
|
2156
2265
|
[[package]]
|
|
2157
2266
|
name = "simple-agents-providers"
|
|
2158
|
-
version = "0.1
|
|
2267
|
+
version = "0.2.1"
|
|
2159
2268
|
dependencies = [
|
|
2160
2269
|
"async-trait",
|
|
2161
2270
|
"bytes",
|
|
@@ -2183,7 +2292,7 @@ dependencies = [
|
|
|
2183
2292
|
|
|
2184
2293
|
[[package]]
|
|
2185
2294
|
name = "simple-agents-py"
|
|
2186
|
-
version = "0.1
|
|
2295
|
+
version = "0.2.1"
|
|
2187
2296
|
dependencies = [
|
|
2188
2297
|
"async-trait",
|
|
2189
2298
|
"futures-util",
|
|
@@ -2202,7 +2311,7 @@ dependencies = [
|
|
|
2202
2311
|
|
|
2203
2312
|
[[package]]
|
|
2204
2313
|
name = "simple-agents-router"
|
|
2205
|
-
version = "0.1
|
|
2314
|
+
version = "0.2.1"
|
|
2206
2315
|
dependencies = [
|
|
2207
2316
|
"async-trait",
|
|
2208
2317
|
"futures-core",
|
|
@@ -2552,13 +2661,18 @@ version = "0.6.8"
|
|
|
2552
2661
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2553
2662
|
checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8"
|
|
2554
2663
|
dependencies = [
|
|
2664
|
+
"async-compression",
|
|
2555
2665
|
"bitflags",
|
|
2556
2666
|
"bytes",
|
|
2667
|
+
"futures-core",
|
|
2557
2668
|
"futures-util",
|
|
2558
2669
|
"http",
|
|
2559
2670
|
"http-body",
|
|
2671
|
+
"http-body-util",
|
|
2560
2672
|
"iri-string",
|
|
2561
2673
|
"pin-project-lite",
|
|
2674
|
+
"tokio",
|
|
2675
|
+
"tokio-util",
|
|
2562
2676
|
"tower",
|
|
2563
2677
|
"tower-layer",
|
|
2564
2678
|
"tower-service",
|
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|
|
3
3
|
resolver = "2"
|
|
4
4
|
|
|
5
5
|
[workspace.package]
|
|
6
|
-
version = "0.1
|
|
6
|
+
version = "0.2.1"
|
|
7
7
|
edition = "2021"
|
|
8
8
|
rust-version = "1.75"
|
|
9
9
|
authors = ["SimpleAgents Contributors"]
|
|
@@ -28,3 +28,6 @@ futures-util = "0.3"
|
|
|
28
28
|
metrics = "0.23"
|
|
29
29
|
metrics-exporter-prometheus = "0.15"
|
|
30
30
|
governor = "0.6"
|
|
31
|
+
simple-agent-type = { version = "0.2.0", path = "crates/simple-agent-type" }
|
|
32
|
+
simple-agents-healing = { version = "0.2.0", path = "crates/simple-agents-healing" }
|
|
33
|
+
simple-agents-providers = { version = "0.2.0", path = "crates/simple-agents-providers" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simple-agents-py
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
|
5
5
|
Classifier: Programming Language :: Rust
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -69,7 +69,7 @@ from simple_agents_py import Client
|
|
|
69
69
|
|
|
70
70
|
client = Client("openai")
|
|
71
71
|
messages = [{"role": "user", "content": "Say hello in one sentence."}]
|
|
72
|
-
for chunk in client.
|
|
72
|
+
for chunk in client.complete("gpt-4o-mini", messages, max_tokens=64, stream=True):
|
|
73
73
|
if chunk.content:
|
|
74
74
|
print(chunk.content, end="", flush=True)
|
|
75
75
|
print()
|
|
@@ -91,7 +91,12 @@ schema = {
|
|
|
91
91
|
"required": ["name", "age"],
|
|
92
92
|
}
|
|
93
93
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
94
|
-
json_text = client.
|
|
94
|
+
json_text = client.complete(
|
|
95
|
+
"gpt-4o-mini",
|
|
96
|
+
messages,
|
|
97
|
+
schema=schema,
|
|
98
|
+
schema_name="person",
|
|
99
|
+
)
|
|
95
100
|
print(json.loads(json_text))
|
|
96
101
|
```
|
|
97
102
|
|
|
@@ -107,7 +112,12 @@ class Person(BaseModel):
|
|
|
107
112
|
|
|
108
113
|
client = Client("openai")
|
|
109
114
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
110
|
-
json_text = client.
|
|
115
|
+
json_text = client.complete(
|
|
116
|
+
"gpt-4o-mini",
|
|
117
|
+
messages,
|
|
118
|
+
schema=Person,
|
|
119
|
+
schema_name="person",
|
|
120
|
+
)
|
|
111
121
|
print(json_text)
|
|
112
122
|
```
|
|
113
123
|
|
|
@@ -129,7 +139,13 @@ schema = {
|
|
|
129
139
|
"required": ["name", "age"],
|
|
130
140
|
}
|
|
131
141
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
132
|
-
for event in client.
|
|
142
|
+
for event in client.complete(
|
|
143
|
+
"gpt-4o-mini",
|
|
144
|
+
messages,
|
|
145
|
+
schema=schema,
|
|
146
|
+
max_tokens=64,
|
|
147
|
+
stream=True,
|
|
148
|
+
):
|
|
133
149
|
if event.is_partial:
|
|
134
150
|
print("partial:", event.partial_value)
|
|
135
151
|
else:
|
|
@@ -143,7 +159,13 @@ from simple_agents_py import Client
|
|
|
143
159
|
|
|
144
160
|
client = Client("openai")
|
|
145
161
|
messages = [{"role": "user", "content": "Return JSON: {\"name\":\"Sam\",\"age\":30}"}]
|
|
146
|
-
healed = client.
|
|
162
|
+
healed = client.complete(
|
|
163
|
+
"gpt-4o-mini",
|
|
164
|
+
messages,
|
|
165
|
+
max_tokens=64,
|
|
166
|
+
response_format="json",
|
|
167
|
+
heal=True,
|
|
168
|
+
)
|
|
147
169
|
print(healed.content)
|
|
148
170
|
print(healed.was_healed, healed.confidence)
|
|
149
171
|
print(healed.usage.get("total_tokens"))
|
|
@@ -173,7 +195,7 @@ tools = [
|
|
|
173
195
|
}
|
|
174
196
|
]
|
|
175
197
|
messages = [{"role": "user", "content": "What's the weather in Tokyo?"}]
|
|
176
|
-
response = client.
|
|
198
|
+
response = client.complete("gpt-4o-mini", messages, tools=tools)
|
|
177
199
|
print(response.tool_calls)
|
|
178
200
|
```
|
|
179
201
|
|
|
@@ -54,7 +54,7 @@ from simple_agents_py import Client
|
|
|
54
54
|
|
|
55
55
|
client = Client("openai")
|
|
56
56
|
messages = [{"role": "user", "content": "Say hello in one sentence."}]
|
|
57
|
-
for chunk in client.
|
|
57
|
+
for chunk in client.complete("gpt-4o-mini", messages, max_tokens=64, stream=True):
|
|
58
58
|
if chunk.content:
|
|
59
59
|
print(chunk.content, end="", flush=True)
|
|
60
60
|
print()
|
|
@@ -76,7 +76,12 @@ schema = {
|
|
|
76
76
|
"required": ["name", "age"],
|
|
77
77
|
}
|
|
78
78
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
79
|
-
json_text = client.
|
|
79
|
+
json_text = client.complete(
|
|
80
|
+
"gpt-4o-mini",
|
|
81
|
+
messages,
|
|
82
|
+
schema=schema,
|
|
83
|
+
schema_name="person",
|
|
84
|
+
)
|
|
80
85
|
print(json.loads(json_text))
|
|
81
86
|
```
|
|
82
87
|
|
|
@@ -92,7 +97,12 @@ class Person(BaseModel):
|
|
|
92
97
|
|
|
93
98
|
client = Client("openai")
|
|
94
99
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
95
|
-
json_text = client.
|
|
100
|
+
json_text = client.complete(
|
|
101
|
+
"gpt-4o-mini",
|
|
102
|
+
messages,
|
|
103
|
+
schema=Person,
|
|
104
|
+
schema_name="person",
|
|
105
|
+
)
|
|
96
106
|
print(json_text)
|
|
97
107
|
```
|
|
98
108
|
|
|
@@ -114,7 +124,13 @@ schema = {
|
|
|
114
124
|
"required": ["name", "age"],
|
|
115
125
|
}
|
|
116
126
|
messages = [{"role": "user", "content": "Extract name and age: Alice is 28."}]
|
|
117
|
-
for event in client.
|
|
127
|
+
for event in client.complete(
|
|
128
|
+
"gpt-4o-mini",
|
|
129
|
+
messages,
|
|
130
|
+
schema=schema,
|
|
131
|
+
max_tokens=64,
|
|
132
|
+
stream=True,
|
|
133
|
+
):
|
|
118
134
|
if event.is_partial:
|
|
119
135
|
print("partial:", event.partial_value)
|
|
120
136
|
else:
|
|
@@ -128,7 +144,13 @@ from simple_agents_py import Client
|
|
|
128
144
|
|
|
129
145
|
client = Client("openai")
|
|
130
146
|
messages = [{"role": "user", "content": "Return JSON: {\"name\":\"Sam\",\"age\":30}"}]
|
|
131
|
-
healed = client.
|
|
147
|
+
healed = client.complete(
|
|
148
|
+
"gpt-4o-mini",
|
|
149
|
+
messages,
|
|
150
|
+
max_tokens=64,
|
|
151
|
+
response_format="json",
|
|
152
|
+
heal=True,
|
|
153
|
+
)
|
|
132
154
|
print(healed.content)
|
|
133
155
|
print(healed.was_healed, healed.confidence)
|
|
134
156
|
print(healed.usage.get("total_tokens"))
|
|
@@ -158,7 +180,7 @@ tools = [
|
|
|
158
180
|
}
|
|
159
181
|
]
|
|
160
182
|
messages = [{"role": "user", "content": "What's the weather in Tokyo?"}]
|
|
161
|
-
response = client.
|
|
183
|
+
response = client.complete("gpt-4o-mini", messages, tools=tools)
|
|
162
184
|
print(response.tool_calls)
|
|
163
185
|
```
|
|
164
186
|
|
|
@@ -11,7 +11,7 @@ documentation.workspace = true
|
|
|
11
11
|
description = "Caching utilities for SimpleAgents"
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
|
-
simple-agent-type = {
|
|
14
|
+
simple-agent-type = { workspace = true }
|
|
15
15
|
tokio = { workspace = true, features = ["sync", "time"] }
|
|
16
16
|
async-trait.workspace = true
|
|
17
17
|
|
|
@@ -132,11 +132,31 @@ impl InMemoryCache {
|
|
|
132
132
|
#[async_trait]
|
|
133
133
|
impl Cache for InMemoryCache {
|
|
134
134
|
async fn get(&self, key: &str) -> Result<Option<Vec<u8>>> {
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
{
|
|
136
|
+
let store = self.store.read().await;
|
|
137
|
+
match store.get(key) {
|
|
138
|
+
Some(entry) if !entry.is_expired() => {
|
|
139
|
+
drop(store);
|
|
140
|
+
|
|
141
|
+
let mut store = self.store.write().await;
|
|
142
|
+
if let Some(entry) = store.get_mut(key) {
|
|
143
|
+
if entry.is_expired() {
|
|
144
|
+
store.remove(key);
|
|
145
|
+
return Ok(None);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
entry.touch();
|
|
149
|
+
return Ok(Some(entry.data.clone()));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return Ok(None);
|
|
153
|
+
}
|
|
154
|
+
Some(_) => {} // expired; clean up below
|
|
155
|
+
None => return Ok(None),
|
|
156
|
+
}
|
|
157
|
+
}
|
|
137
158
|
|
|
138
159
|
let mut store = self.store.write().await;
|
|
139
|
-
|
|
140
160
|
if let Some(entry) = store.get_mut(key) {
|
|
141
161
|
if entry.is_expired() {
|
|
142
162
|
store.remove(key);
|
|
@@ -162,6 +182,9 @@ impl Cache for InMemoryCache {
|
|
|
162
182
|
store.insert(key.to_string(), entry);
|
|
163
183
|
}
|
|
164
184
|
|
|
185
|
+
// Periodically clear expired entries before enforcing limits
|
|
186
|
+
self.evict_expired().await;
|
|
187
|
+
|
|
165
188
|
// Evict if needed
|
|
166
189
|
self.evict_lru().await;
|
|
167
190
|
|
|
@@ -324,6 +347,25 @@ mod tests {
|
|
|
324
347
|
assert!(cache.get("key3").await.unwrap().is_some());
|
|
325
348
|
}
|
|
326
349
|
|
|
350
|
+
#[tokio::test]
|
|
351
|
+
async fn test_concurrent_gets_do_not_serialize_readers() {
|
|
352
|
+
let cache = Arc::new(InMemoryCache::new(1024, 10));
|
|
353
|
+
cache
|
|
354
|
+
.set("shared", b"value".to_vec(), Duration::from_secs(60))
|
|
355
|
+
.await
|
|
356
|
+
.unwrap();
|
|
357
|
+
|
|
358
|
+
let mut handles = Vec::new();
|
|
359
|
+
for _ in 0..25 {
|
|
360
|
+
let cache = cache.clone();
|
|
361
|
+
handles.push(tokio::spawn(async move { cache.get("shared").await.unwrap() }));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
for handle in handles {
|
|
365
|
+
assert_eq!(handle.await.unwrap(), Some(b"value".to_vec()));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
327
369
|
#[tokio::test]
|
|
328
370
|
async fn test_cache_name() {
|
|
329
371
|
let cache = InMemoryCache::new(1024, 10);
|
|
@@ -16,11 +16,13 @@ async-trait.workspace = true
|
|
|
16
16
|
serde.workspace = true
|
|
17
17
|
serde_json.workspace = true
|
|
18
18
|
tokio.workspace = true
|
|
19
|
+
futures-util.workspace = true
|
|
20
|
+
tracing = "0.1"
|
|
19
21
|
|
|
20
|
-
simple-agent-type = {
|
|
21
|
-
simple-agents-router = { path = "../simple-agents-router", version = "0.1
|
|
22
|
-
simple-agents-cache = { path = "../simple-agents-cache", version = "0.1
|
|
23
|
-
simple-agents-healing = { path = "../simple-agents-healing", version = "0.1
|
|
22
|
+
simple-agent-type = { workspace = true }
|
|
23
|
+
simple-agents-router = { path = "../simple-agents-router", version = "0.2.1" }
|
|
24
|
+
simple-agents-cache = { path = "../simple-agents-cache", version = "0.2.1" }
|
|
25
|
+
simple-agents-healing = { path = "../simple-agents-healing", version = "0.2.1" }
|
|
24
26
|
futures-core = "0.3"
|
|
25
27
|
|
|
26
28
|
[dev-dependencies]
|
|
@@ -15,7 +15,9 @@ healing, and middleware into a single entry point.
|
|
|
15
15
|
|
|
16
16
|
```rust
|
|
17
17
|
use async_trait::async_trait;
|
|
18
|
-
use simple_agents_core::{
|
|
18
|
+
use simple_agents_core::{
|
|
19
|
+
CompletionOptions, CompletionOutcome, RoutingMode, SimpleAgentsClientBuilder,
|
|
20
|
+
};
|
|
19
21
|
use simple_agent_type::prelude::*;
|
|
20
22
|
use std::sync::Arc;
|
|
21
23
|
|
|
@@ -59,7 +61,11 @@ let request = CompletionRequest::builder()
|
|
|
59
61
|
.message(Message::user("Hello"))
|
|
60
62
|
.build()?;
|
|
61
63
|
|
|
62
|
-
let
|
|
64
|
+
let outcome = client.complete(&request, CompletionOptions::default()).await?;
|
|
65
|
+
let response = match outcome {
|
|
66
|
+
CompletionOutcome::Response(response) => response,
|
|
67
|
+
_ => return Ok(()),
|
|
68
|
+
};
|
|
63
69
|
println!("{}", response.content().unwrap_or(""));
|
|
64
70
|
# Ok(())
|
|
65
71
|
# }
|
|
@@ -72,7 +78,7 @@ Use healing for JSON outputs:
|
|
|
72
78
|
```rust
|
|
73
79
|
use simple_agents_healing::schema::Schema;
|
|
74
80
|
# use simple_agent_type::prelude::*;
|
|
75
|
-
# use simple_agents_core::SimpleAgentsClientBuilder;
|
|
81
|
+
# use simple_agents_core::{CompletionMode, CompletionOptions, CompletionOutcome, SimpleAgentsClientBuilder};
|
|
76
82
|
# use std::sync::Arc;
|
|
77
83
|
# use async_trait::async_trait;
|
|
78
84
|
# struct MockProvider;
|
|
@@ -113,7 +119,18 @@ let request = CompletionRequest::builder()
|
|
|
113
119
|
.message(Message::user("Give JSON"))
|
|
114
120
|
.build()?;
|
|
115
121
|
|
|
116
|
-
let healed = client
|
|
122
|
+
let healed = client
|
|
123
|
+
.complete(
|
|
124
|
+
&request,
|
|
125
|
+
CompletionOptions {
|
|
126
|
+
mode: CompletionMode::CoercedSchema(schema),
|
|
127
|
+
},
|
|
128
|
+
)
|
|
129
|
+
.await?;
|
|
130
|
+
let healed = match healed {
|
|
131
|
+
CompletionOutcome::CoercedSchema(healed) => healed,
|
|
132
|
+
_ => return Ok(()),
|
|
133
|
+
};
|
|
117
134
|
assert_eq!(healed.coerced.value["count"], 5);
|
|
118
135
|
# Ok(())
|
|
119
136
|
# }
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
use async_trait::async_trait;
|
|
2
|
-
use simple_agents_core::{RoutingMode, SimpleAgentsClientBuilder};
|
|
3
2
|
use simple_agent_type::prelude::*;
|
|
3
|
+
use simple_agents_core::{
|
|
4
|
+
CompletionOptions, CompletionOutcome, RoutingMode, SimpleAgentsClientBuilder,
|
|
5
|
+
};
|
|
4
6
|
use std::sync::Arc;
|
|
5
7
|
|
|
6
8
|
struct MockProvider;
|
|
@@ -49,7 +51,13 @@ async fn main() -> Result<()> {
|
|
|
49
51
|
.message(Message::user("Say hi"))
|
|
50
52
|
.build()?;
|
|
51
53
|
|
|
52
|
-
let
|
|
54
|
+
let outcome = client
|
|
55
|
+
.complete(&request, CompletionOptions::default())
|
|
56
|
+
.await?;
|
|
57
|
+
let response = match outcome {
|
|
58
|
+
CompletionOutcome::Response(response) => response,
|
|
59
|
+
_ => return Ok(()),
|
|
60
|
+
};
|
|
53
61
|
println!("{}", response.content().unwrap_or_default());
|
|
54
62
|
|
|
55
63
|
Ok(())
|