Repository navigation
5. Subject finetuner
Important
The details presented in this document are generated in part automatically by AI. Because this document is not regenerated systematically, it may not reflect the latest version of the source code.
| Technical identity | Value |
|---|---|
| Audience | Software developers and functional analysts |
| Namespace | JbtiEvolution.OraklLearn.Generator.Books |
| Main class | TopicFinetuner |
The Subject Finetuner helps a user turn a short learning intention and its keywords into a set of clearer generation prompts. It is an input-quality service: it does not create a book, change the book structure, or persist a publication. Its output gives the structure and book-generation journeys better focused alternatives to review.
- Position in the authoring journey
- Processing contract
- Workflow and trust boundary
- Input, transformation, and output
- Controls and operational behavior
- Code map
flowchart LR
A[Subject and keywords] --> B[Subject Finetuner]
B --> C[Alternative focused prompts]
C --> D[User selects or edits a prompt]
D --> E[Structure Generator]
E --> F[Reviewable book blueprint]
F --> G[Book Generator]
The person creating the learning content remains in control. The finetuner supplies alternatives; the following screen or workflow decides which one, if any, becomes the subject of a structure-generation transaction.
FinetunePrompt(FinetunePromptTransaction transaction, out string[] prompts) is synchronous and returns:
| Result | Meaning |
|---|---|
true and a non-empty array |
The transaction was preauthorized, the subject passed policy checks, the response satisfied the output contract, and the cost was claimed. |
false and an empty array |
Any control or generation step failed. The caller should use the trace to determine the reason and should not treat the input as refined. |
The method returns suggestions directly to its caller. It does not save them as a book or attach them to a user profile as content; only the successful transaction’s cost claim is persisted by this module.
flowchart TD
A[Finetune transaction] --> B[Set Finetune cost]
B --> C{Credit preauthorized?}
C -->|no| X[Return false]
C -->|yes| D{Subject allowed by content policy?}
D -->|no| X
D -->|yes| E[Format subject and keywords]
E --> F[Build refinement prompts]
F --> G[Generative text service]
G --> H{Complete JSON meets contract?}
H -->|no| X
H -->|yes| I{At least one non-empty prompt?}
I -->|no| X
I -->|yes| J[Claim transaction cost]
J --> K[Return prompt array]
The control sequence is deliberately ordered. Credit preauthorization and policy evaluation happen before the generative call. The cost is claimed only after a usable result is available.
| Stage | Technical behavior | Functional value |
|---|---|---|
| Input | Reads Subject and Keywords from the finetune transaction. |
Captures the user’s initial intent. |
| Policy check | Evaluates the subject with the configured moderation capability. | Stops unsuitable topics before prompt creation. |
| Formatting | Applies BookSettings.GetFormattedSubject to combine the subject and keywords. |
Gives the model a consistent context. |
| Prompt construction | Uses PromptBuilder.FinetuneSubject with a target of 100 prompt proposals. |
Requests diverse, usable formulations rather than a single opaque rewrite. |
| Generative response | Invokes the inference scope configured for refinement with JSON output requested. | Separates the provider-specific call from the module’s business behavior. |
| Strict validation | Parses the entire response with LlmOutputGuard.TryParseStrictJson as ResponseFinetune. |
Rejects prose, partial data, injected instructions, malformed JSON, or blank suggestions. |
| Output | Returns ResponseFinetune.Prompts. |
Lets the user or calling workflow choose the final direction. |
The strict response boundary is significant. The module does not attempt to salvage a JSON-looking fragment from surrounding text; it requires a complete payload that conforms to the expected schema.
| Control | Behavior in the implementation |
|---|---|
| Cost selection | Uses the Finetune cost from the transaction’s presented cost. |
| Credit preauthorization | Must succeed before the service sends a refinement request. |
| Subject policy | Evaluates the subject. If any result is flagged, the process records the violation and stops. |
| Response integrity | Requires a complete, schema-valid JSON document with one or more nonblank prompt strings. |
| Cancellation | Passes the request cancellation token to both the policy and generative services. |
| Tracing | Emits start, policy, and validation-failure events and records the configured model scopes at construction. |
| Billing order | Claims credit only after a valid prompt list has been produced. |
There is no internal retry loop in TopicFinetuner. A caller that wants retry behavior should create a new, controlled request rather than assume a failed response was partially accepted.
| Concern | Main implementation point |
|---|---|
| Refinement transaction | TopicFinetuner.FinetunePrompt |
| Generative prompt preparation and response validation | TopicFinetuner.CanOptimize |
| Topic policy evaluation | TopicFinetuner.IsSubjectPoliciesCompliance |
| Prompt template | PromptBuilder.FinetuneSubject |
| Strict structured-output gate | LlmOutputGuard.TryParseStrictJson |
The Subject Finetuner is therefore a guarded preparation step for generative learning-content workflows: it improves the starting instruction while keeping approval, final content selection, and book production outside its scope.

https://orakllearn.com · Author: Jimmy Bourque · https://jbti-evolution.com
- Main page
- Overview
- Foundation
- Integration
- Flow
- Using OraklLearn
- Configuration
- Monitoring