ProxyAiDatasource class
AI datasource that routes through the Supabase Edge Function proxy.
System prompts and content retrieval happen server-side. The user's own credential (API key for Claude, OAuth token for OpenAI/Gemini) is forwarded per-request and never stored on the server.
- Implemented types
Constructors
-
ProxyAiDatasource(Dio _dio, {required AiProvider backendProvider, required String functionUrl, required Map<
String, String> headersBuilder(), required Future<String?> credentialProvider(), String mode = 'explore', String? topicId, bool isValidation = false, String? validationTarget, bool isCardGeneration = false})
Properties
- backendProvider → AiProvider
-
The underlying provider to use on the server (claude, openai, gemini).
final
-
credentialProvider
→ Future<
String?> Function() -
Fetches the user's credential (API key or OAuth token) for the provider.
final
- functionUrl → String
-
Full URL to the ai-proxy Edge Function.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headersBuilder
→ Map<
String, String> Function() -
Auth headers to include with every request.
final
- isCardGeneration → bool
-
Whether this is a card generation request.
final
- isValidation → bool
-
Whether this is a validation session.
final
- mode → String
-
Chat mode (teach, socratic, quiz, etc.) — sent to proxy for prompt selection.
final
- providerName → String
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- topicId → String?
-
Topic ID for content chunk retrieval on the server.
final
- validationTarget → String?
-
Validation target level.
final
Methods
-
isConfigured(
) → Future< bool> -
Whether the provider is configured (API key stored or OAuth signed in).
override
-
listModels(
) → Future< List< AiModel> > -
Fetch available models from the provider's API.
override
-
mapError(
DioException e) → AiApiException -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendMessage(
{required String systemPrompt, required List< Map< messages, int maxTokens = 8192}) → Future<String, String> >String> -
Send messages to the AI proxy. The proxy builds the system prompt
server-side —
systemPromptis ignored (kept for interface compatibility).override -
streamMessage(
{required String systemPrompt, required List< Map< messages, int maxTokens = 8192}) → Stream<String, String> >String> -
Stream a response from the AI proxy via SSE.
systemPromptis ignored — the proxy builds it server-side.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited