Overview

Please note that the larger Mistral models support Mode::Json, which is much more reliable than Mode::MdJson.

Mode compatibility:

  • Mode::Tools - selected models
  • Mode::Json - selected models
  • Mode::MdJson

Example

<?php

use Cognesy\Polyglot\LLM\Inference;
use Cognesy\Utils\Str;

require 'examples/boot.php';

$answer = (new Inference)
    ->withConnection('fireworks') // see /config/llm.php
    ->create(
        messages: [['role' => 'user', 'content' => 'What is the capital of France']],
        options: ['max_tokens' => 64]
    )
    ->toText();

echo "USER: What is capital of France\n";
echo "ASSISTANT: $answer\n";
assert(Str::contains($answer, 'Paris'));
?>