patient_llm 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +380 -193
- data/VERSION +1 -1
- data/lib/patient_llm/agent/failure.rb +76 -0
- data/lib/patient_llm/agent/response.rb +111 -0
- data/lib/patient_llm/agent.rb +716 -0
- data/lib/patient_llm/aws_request_signer.rb +195 -0
- data/lib/patient_llm/callback.rb +122 -53
- data/lib/patient_llm/configuration.rb +154 -31
- data/lib/patient_llm/max_tool_iterations_error.rb +5 -5
- data/lib/patient_llm/presets.rb +76 -0
- data/lib/patient_llm/schema.rb +105 -0
- data/lib/patient_llm/structured_output_error.rb +15 -0
- data/lib/patient_llm.rb +191 -43
- data/patient_llm.gemspec +3 -6
- metadata +14 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e41751b511195c13cb2ce097a6c4bd7c7eac6b5396d9194cc0c831dfc37213bc
|
|
4
|
+
data.tar.gz: 245940b4b96b8c558c417945564f64a03866a75d4715600cbb2232be69d9f8d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ed8d318bdbf43564895ab93bfe6020abdded82573d042e2d568bf598af595d769520dd3b61ca348dd05a0a8796da2900e0c70fa204ff6884c9d170c4f777edc
|
|
7
|
+
data.tar.gz: a93fed561708169bcb3b6f38c5db9158a4079a0e1d8e400af3892d1cd3fe198aa75648e080a685022b864aec6954bc082a359ac9fc25e457a25442f7999a4f12
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 0.5.0
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added `PatientLLM::Agent`, a declarative base class bundling provider, model, system, generation settings, tools (schema and handler together as instance methods), structured output schema, and completion handling in one class. Call with `MyAgent.ask(message, context: {...})`, continue persisted conversations with `MyAgent.continue(state, message)` (the agent's current configuration is re-applied to the restored session), and run inline for consoles and tests with `MyAgent.ask!`. Declarations accept blocks or callables resolved at request time, and `extra` declares provider-specific session data. Responses are handled by `completed(response)`, `failed(failure)`, and `tool_round(response)` hooks, redirectable to another class with the `callback:` option: successes receive an `Agent::Response` and failures an `Agent::Failure`, each bundling the whole invocation — the context passed to `ask`/`continue`, the HTTP exchange (`http_response`/`http_request_id`, nil for non-HTTP errors), the session, and the response text/structured output (`object`, which raises `PatientLLM::StructuredOutputError` when parsing fails) or error. Both objects support `[]` as a shorthand for reading a context value (`response[:trip_id]`). Tool methods can opt into the context by declaring a `context:` keyword.
|
|
12
|
+
- Added `PatientLLM::Schema`, a minimal JSON Schema builder used by the Agent DSL for tool parameters and output schemas. Raw JSON Schema hashes are accepted everywhere as an escape hatch.
|
|
13
|
+
- Added built-in provider presets (`:openai`, `:anthropic`, `:gemini`, `:bedrock_runtime`) supplying each vendor's URL, serializer, authentication header, and API key format: `config.provider :anthropic, preset: :anthropic, api_key: -> { ENV["ANTHROPIC_API_KEY"] }`. `url:` is no longer required when a preset supplies it; `:bedrock_runtime` requires a `region:` option instead. The `api_key` option registers the key as a PatientHttp secret named `patient_llm.<provider>.api_key` automatically — no separate `register_secret` step or hand-matched name strings.
|
|
14
|
+
- Added `PatientLLM.verify_configuration!` to check at boot time that a request handler is registered and that every secret and preprocessor referenced by a provider is registered.
|
|
15
|
+
- Added `timeout:` and `max_tool_iterations:` options to provider configuration and `PatientLLM.ask`. Both are preserved across automatic tool-loop iterations.
|
|
16
|
+
- Provider configuration options can now be callables, evaluated each time the provider is looked up so values can be generated dynamically at runtime. Validation of a callable's result happens at lookup time.
|
|
17
|
+
- Added `PatientLLM.inline { ... }` to execute requests (including the automatic tool loop) synchronously in-process without a job-system handler.
|
|
18
|
+
- Added optional session offloading for large conversations: `config.session_offload payload_store: :name, threshold: bytes` stores oversized sessions in a PatientHttp payload store and passes them by reference through the job queue.
|
|
19
|
+
- The automatic tool loop can now resolve tool handlers from the user callback itself when it implements `handles_tool?`/`invoke_tool` (as `PatientLLM::Agent` does), falling back to the global `PromptBuilder.tool_registry`.
|
|
20
|
+
- Added `PatientLLM::AwsRequestSigner`, a callable helper for signing requests with AWS SigV4 that can be registered directly as a PatientHttp request preprocessor (e.g. for Bedrock). It takes a credential chain, credentials provider, or static credentials object, and derives the signing service and region from the request URL host when not given explicitly. Requires the aws-sigv4 gem, which is not a dependency of this gem.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- The serializer is now resolved once at enqueue time and travels with the request, so the response is always parsed with the same format the payload was built with even if provider configuration differs between processes.
|
|
25
|
+
- `MAX_TOOL_ITERATIONS` is now a default rather than a hard cap; the resolved limit travels with the request.
|
|
26
|
+
- The default `:converse` path is now `model/{model}/converse` (was `converse`), and the model substituted into a `{model}` placeholder is percent-encoded so Bedrock ARN model ids form a single path segment.
|
|
27
|
+
- The hardcoded `/v1/chat/completions` last-resort path fallback was removed, and a `{model}` placeholder with no session model now raises `ArgumentError`.
|
|
28
|
+
- Callback args are deep-converted to JSON-native values (previously only the top-level keys were stringified).
|
|
29
|
+
- When a tool halts the loop, the remaining tool calls in that round receive a "Tool execution halted" output instead of being skipped, and the synthesized halt message no longer advances the session's response boundary.
|
|
30
|
+
- Requires patient_http 1.3 and prompt_builder 0.3.
|
|
31
|
+
- Minimum Ruby version is now 3.2.
|
|
32
|
+
|
|
33
|
+
### Removed
|
|
34
|
+
|
|
35
|
+
- Removed the deprecated `completion_path:` argument from `PatientLLM.ask` and provider configuration; use `path:`.
|
|
36
|
+
- Removed the internal `tool_iteration:` and `original_request_id:` arguments from the public `PatientLLM.ask` signature.
|
|
37
|
+
|
|
7
38
|
## 0.4.0
|
|
8
39
|
|
|
9
40
|
### Added
|