LLMProvider class abstract

Abstract interface for LLM (Large Language Model) providers.

This interface defines the contract that all LLM providers must implement to be used with Spectra. Providers handle the actual communication with AI services (OpenAI, Anthropic, Google, etc.).

Implementing a Provider

To create a new provider, extend this class and implement:

Example

class MyProvider implements LLMProvider {
  @override
  String get name => 'MyProvider';

  @override
  List<String> get availableModels => ['model-1', 'model-2'];

  @override
  String get defaultModel => 'model-1';

  @override
  Future<String> generateResponse(String prompt, {List<String>? context}) async {
    // Implementation here
  }
}
Implementers

Constructors

LLMProvider()

Properties

availableModels List<String>
List of model names available from this provider.
no setter
defaultModel String
The default model to use if none is specified.
no setter
hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable name of this provider (e.g., "OpenAI", "Claude").
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generateResponse(String prompt, {List<String>? context}) Future<String>
Generates a response from the LLM based on the given prompt.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited