<?php
use Cognesy\Polyglot\Embeddings\Embeddings;
// Example with OpenAI-specific options
$openaiEmbeddings = new Embeddings('openai');
$response = $openaiEmbeddings->with(
input: ["Sample text for embedding"],
options: [
'encoding_format' => 'float', // Get float values instead of base64
'dimensions' => 512, // Request a specific vector size (if supported)
]
)->get();
// Example with Cohere-specific options
$cohereEmbeddings = new Embeddings('cohere');
$response = $cohereEmbeddings->with(
input: ["Sample text for embedding"],
options: [
'input_type' => 'classification', // Cohere-specific option
'truncate' => 'END', // How to handle texts that exceed the token limit
]
)->get();
// @doctest id="ddd4"