Whisper implements Pipeline
Implements the OpenAI Whisper pipeline for audio transcription.
This pipeline uses an underlying driver (default: GuzzleDriver) to communicate with the OpenAI Whisper API. It expects a prompt of type FSprompt containing file input, configures the driver to use multipart form data, and returns the transcribed text from the API response.
Table of Contents
Interfaces
- Pipeline
- Defines the required methods for Ai Model Pipelines, which are required for compatibility with LaravelNeuro Agent Networking features.
Properties
- $accessToken : mixed
- The OpenAI access token retrieved from configuration.
- $driver : GuzzleDriver
- The driver instance used for HTTP requests.
- $model : mixed
- The model identifier used for the API request.
- $prompt : mixed
- The prompt data.
Methods
- __construct() : mixed
- Whisper constructor.
- driver() : Driver
- Accesses the injected Driver instance.
- driverClass() : string
- Retrieves the class name of the default associated driver.
- getDriver() : Driver
- Retrieves the current driver.
- getModel() : mixed
- Retrieves the current model identifier.
- getPrompt() : mixed
- Retrieves the current prompt.
- output() : mixed
- Executes the API request and returns the transcribed text.
- promptClass() : string
- Retrieves the class name of the default associated prompt.
- setModel() : self
- Sets the model for the pipeline.
- setPrompt() : self
- Sets the prompt for the pipeline.
- stream() : Generator
- Executes a streaming API request.
Properties
$accessToken
The OpenAI access token retrieved from configuration.
protected
mixed
$accessToken
$driver
The driver instance used for HTTP requests.
protected
GuzzleDriver
$driver
$model
The model identifier used for the API request.
protected
mixed
$model
$prompt
The prompt data.
protected
mixed
$prompt
Methods
__construct()
Whisper constructor.
public
__construct([Driver $driver = new GuzzleDriver() ]) : mixed
Retrieves configuration values for the Whisper model and API endpoint, initializes the underlying driver (defaulting to GuzzleDriver), sets the required HTTP header for authorization, and validates that all required configuration values are provided.
Parameters
- $driver : Driver = new GuzzleDriver()
-
An instance implementing the Driver contract.
Tags
driver()
Accesses the injected Driver instance.
public
driver() : Driver
Return values
Driver —the Driver instance stored in this instance of the class.
driverClass()
Retrieves the class name of the default associated driver.
public
driverClass() : string
Return values
stringgetDriver()
Retrieves the current driver.
public
getDriver() : Driver
Return values
Driver —The driver instance.
getModel()
Retrieves the current model identifier.
public
getModel() : mixed
Return values
mixed —The model identifier.
getPrompt()
Retrieves the current prompt.
public
getPrompt() : mixed
Return values
mixed —The prompt data.
output()
Executes the API request and returns the transcribed text.
public
output() : mixed
Parses the API response and returns the "text" field.
Return values
mixed —The transcribed text.
promptClass()
Retrieves the class name of the default associated prompt.
public
promptClass() : string
Return values
stringsetModel()
Sets the model for the pipeline.
public
setModel(mixed $model) : self
Updates the pipeline's model property and informs the driver of the model.
Parameters
- $model : mixed
-
The model identifier.
Return values
selfsetPrompt()
Sets the prompt for the pipeline.
public
setPrompt(FSprompt $prompt) : self
Expects an instance of FSprompt, which provides the file to be transcribed. Configures the driver to use multipart form data by setting the request type to MULTIPART, and updates the driver's request payload with the file parameter.
Parameters
- $prompt : FSprompt
-
A FSprompt instance containing file input.
Tags
Return values
selfstream()
Executes a streaming API request.
public
stream() : Generator
This pipeline does not support streaming mode.