Skip to content

Add support for Jev-style decision models - #103

Merged
jeffpaul merged 8 commits into
developfrom
feature/decision-model
Oct 1, 2026
Merged

jeffpaul merged 8 commits into
developfrom
feature/decision-model

Conversation

@dkotter

@dkotter dkotter commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description of the Change

The latest version of Ollama (v0.35) added support for Jev-style decision models. Since these models function differently than a standard text-generation model, they aren't natively supported with the PHP AI Client (see WordPress/php-ai-client#296 that is tracking this). This means in order to make these models work here, we need to add our own custom model support for now, which is what this PR does (ideally most of this is added to the PHP AI Client and the code here can then be simplified).

  • We add an OllamaDecisionModel class that is responsible for making API requests to a decision model via the /v1/systemone endpoint
  • We add a new static method decisionModel that can be used directly to call a decision model. This is the only entry point until the PHP AI Client properly supports decision model routing
  • We update our model mapping to ensure decision models have proper capabilities set
  • And we add all the necessary decision model DTOs

How to test the Change

  1. Install Ollama 0.35 or later and pull a decision model. tev1:0.8b is the smallest:
    ollama pull tev1:0.8b
    
  2. Pull the changes from this branch and activate the plugin.
  3. Save this as test-decisions.php and run wp eval-file test-decisions.php:
<?php
use Fueled\AiProviderForOllama\Decisions\DecisionQuestion;
use Fueled\AiProviderForOllama\Provider\OllamaProvider;

// 1. Discovery: should list only models that report the "decision" capability.
$models = OllamaProvider::decisionModelIds();
WP_CLI::log( 'Decision models: ' . ( $models ? implode( ', ', $models ) : 'none found' ) );
if ( ! $models ) {
      WP_CLI::error( 'Pull a decision model first, e.g. `ollama pull tev1:0.8b`.' );
}

// 2. One request with all three question types.
$result = OllamaProvider::decisionModel( $models[0] )->decide(
      array(
              'ticket'   => 'Our checkout has returned 500 errors since 9am.',
              'customer' => 'enterprise',
      ),
      array(
              'label'    => DecisionQuestion::choice(
                      'Which label fits this ticket?',
                      array(
                              'billing' => 'Payments and refunds',
                              'bug'     => 'Software errors',
                              'account' => 'Login and account access',
                      )
              ),
              'urgent'   => DecisionQuestion::noul( 'Is this urgent?' ),
              'severity' => DecisionQuestion::score( 'How severe is this?', array( 'Trivial', 'Minor', 'Major', 'Critical' ) ),
      )
);

$label    = $result->getAnswer( 'label' );
$urgent   = $result->getAnswer( 'urgent' );
$severity = $result->getAnswer( 'severity' );

WP_CLI::log( sprintf( 'label:    %s (confidence %.2f, confident at 0.8: %s)', $label->getChoice(), $label->getConfidence(),
$label->isConfident( 0.8 ) ? 'yes' : 'no' ) );
WP_CLI::log( sprintf( 'urgent:   %.3f probability of yes', $urgent->getProbability() ) );
WP_CLI::log( sprintf( 'severity: %.2f on a 0-3 scale (confidence %.2f)', $severity->getScore(), $severity->getConfidence() ) );
WP_CLI::log( sprintf( 'tokens:   %d in / %d out', $result->getTokenUsage()->getPromptTokens(),$result->getTokenUsage()->getCompletionTokens() ) );

// 3. Invalid input is rejected before any request is sent.
try {
      DecisionQuestion::choice( 'Pick one.', array( 'only' => 'A single option' ) );
} catch ( \Throwable $e ) {
      WP_CLI::log( 'Validation: ' . $e->getMessage() );
}

WP_CLI::success( 'Decision request completed.' );

Expected Result:

➜ wp eval-file test-decisions.php                                       
Decision models: tev1:latest
label:    bug (confidence 0.82, confident at 0.8: yes)
urgent:   0.901 probability of yes
severity: 2.30 on a 0-3 scale (confidence 0.26)
tokens:   753 in / 4 out
Validation: A choice question needs between 2 and 26 criteria, 1 given.
Success: Decision request completed.

Also check that a normal text prompt with no model specified, e.g. wp_ai_client_prompt( 'Hi' )->using_provider( 'ollama' )->generate_text(), doesn't use the decision model when other models are installed.

Changelog Entry

Added - Support for Jev-style decision models

Credits

Props @dkotter

Checklist:

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.3.0 milestone Sep 30, 2026
@dkotter dkotter self-assigned this Sep 30, 2026
@jeffpaul

Copy link
Copy Markdown
Collaborator

My local results:

Decision models: tev1:0.8b
label:    bug (confidence 0.86, confident at 0.8: yes)
urgent:   0.782 probability of yes
severity: 1.32 on a 0-3 scale (confidence 0.40)
tokens:   753 in / 4 out
Validation: A choice question needs between 2 and 26 criteria, 1 given.
Success: Decision request completed.

Do we want to add Decision pill as a model capability or do you think Text generation, Chat history, and Tools suffice?

@dkotter

dkotter commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Do we want to add Decision pill as a model capability or do you think Text generation, Chat history, and Tools suffice?

The issue here is these pills currently output capabilities that the PHP AI Client is returning and "Decision" isn't yet a supported capability there.

If you want to see that output here, we could hardcode that capability ourselves until it is supported upstream, just something we'll need to remember to come back to and remove.

@jeffpaul

jeffpaul commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Ok, we'll just await the PHP client allowing for that

@jeffpaul
jeffpaul merged commit 9628279 into develop Oct 1, 2026
29 checks passed
@jeffpaul
jeffpaul deleted the feature/decision-model branch October 1, 2026 16:14
@dkotter dkotter mentioned this pull request Oct 26, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants