CompletionService
-
class
CompletionService -
- Fully qualified name
-
\Netresearch\Nr Llm\ Service\ Feature\ Completion Service
High-level text completion with format control.
complete(string $prompt, ?ChatOptions $options = null): CompletionResponse-
Standard text completion.
- param string $prompt
-
The prompt text
- param ?ChatOptions $options
-
Optional configuration
- Returns
-
CompletionResponse
completeJson(string $prompt, ?ChatOptions $options = null): array-
Completion with JSON output parsing.
- param string $prompt
-
The prompt text
- param ?ChatOptions $options
-
Optional configuration
- Returns
-
array Parsed JSON data
completeMarkdown(string $prompt, ?ChatOptions $options = null): string-
Completion with markdown formatting.
- param string $prompt
-
The prompt text
- param ?ChatOptions $options
-
Optional configuration
- Returns
-
string Markdown formatted text
completeFactual(string $prompt, ?ChatOptions $options = null): CompletionResponse-
Low-creativity completion for factual responses.
- param string $prompt
-
The prompt text
- param ?ChatOptions $options
-
Optional configuration (temperature defaults to 0.1)
- Returns
-
CompletionResponse
completeCreative(string $prompt, ?ChatOptions $options = null): CompletionResponse-
High-creativity completion for creative content.
- param string $prompt
-
The prompt text
- param ?ChatOptions $options
-
Optional configuration (temperature defaults to 1.2)
- Returns
-
CompletionResponse
completeStructured(string $prompt, array $schema, ?ChatOptions $options = null): array-
Completion validated against a JSON schema from the strict named subset (ADR-126):
type,enum,const,pattern, lengths, numeric bounds,items,properties/required/additionaland the combinators —Properties $refis deliberately out. The schema is pre-flighted BEFORE the first provider call (an out-of-subset schema throws code1784500003instead of costing paid requests), enforced provider-natively where the provider can (ADR-128), validated strictly on the response, and repaired with one controlled round-trip on a mismatch.- param string $prompt
-
The prompt text
- param array $schema
-
JSON schema inside the strict subset
- param ?ChatOptions $options
-
Optional configuration
- throws
-
InvalidArgumentException on an out-of-subset schema (
1784500003) or when the response still fails the schema after one repair attempt (1784500001)
- Returns
-
array The decoded, schema-valid JSON payload
Every method above also exists as a
*Forvariant taking a persistedConfiguration () Llmas its second argument — the call then runs with that configuration's provider, model, options and skills instead of the system default.Configuration