Improve LLM provider configuration
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:relationship_saver/core/llm/llm_config.dart';
|
||||
|
||||
void main() {
|
||||
test('cloud provider defaults need an API key', () {
|
||||
final LlmConfigState missingKey = LlmConfigState(
|
||||
provider: LlmProvider.openai,
|
||||
);
|
||||
final LlmConfigState configured = LlmConfigState(
|
||||
apiKeyConfigured: true,
|
||||
provider: LlmProvider.openai,
|
||||
);
|
||||
|
||||
expect(missingKey.isConfigured, isFalse);
|
||||
expect(configured.isConfigured, isTrue);
|
||||
expect(configured.baseUrl, 'https://api.openai.com/v1');
|
||||
expect(configured.model, 'gpt-4o-mini');
|
||||
});
|
||||
|
||||
test('local providers can be configured without an API key', () {
|
||||
final LlmConfigState ollama = LlmConfigState(
|
||||
provider: LlmProvider.ollama,
|
||||
baseUrl: 'http://192.168.1.12:11434',
|
||||
model: 'llama3.2:latest',
|
||||
);
|
||||
final LlmConfigState compatible = LlmConfigState(
|
||||
provider: LlmProvider.openaiCompatible,
|
||||
baseUrl: 'http://localhost:8000/v1',
|
||||
model: 'local-model',
|
||||
);
|
||||
|
||||
expect(ollama.isConfigured, isTrue);
|
||||
expect(compatible.isConfigured, isTrue);
|
||||
});
|
||||
|
||||
test('local providers still require a model and endpoint', () {
|
||||
final LlmConfigState missingModel = LlmConfigState(
|
||||
provider: LlmProvider.ollama,
|
||||
baseUrl: 'http://localhost:11434',
|
||||
);
|
||||
final LlmConfigState missingEndpoint = LlmConfigState(
|
||||
provider: LlmProvider.openaiCompatible,
|
||||
model: 'local-model',
|
||||
);
|
||||
|
||||
expect(missingModel.isConfigured, isFalse);
|
||||
expect(missingEndpoint.isConfigured, isFalse);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user