mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
fixes
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'dart:io' show Platform;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:genai/models/ai_request_model.dart';
|
||||
import 'package:genai/interface/consts.dart';
|
||||
import 'package:genai/utils/ai_request_utils.dart';
|
||||
import 'package:better_networking/better_networking.dart';
|
||||
|
||||
const kTestingAPIKey = "XXXXXXXXXXXX";
|
||||
const kGeminiApiKey = 'GEMINI_API_KEY';
|
||||
|
||||
void main() {
|
||||
group('ai_request_utils', () {
|
||||
test(
|
||||
'executeGenAIRequest should return formatted output on success',
|
||||
() async {
|
||||
const model = AIRequestModel(
|
||||
Map<String, String> envVars = Platform.environment;
|
||||
String? kTestingAPIKey;
|
||||
if (envVars.containsKey(kGeminiApiKey)) {
|
||||
kTestingAPIKey = envVars[kGeminiApiKey];
|
||||
} else {
|
||||
throw ArgumentError(
|
||||
'$kGeminiApiKey should be available as an environment variable.',
|
||||
);
|
||||
}
|
||||
var model = AIRequestModel(
|
||||
modelApiProvider: ModelAPIProvider.gemini,
|
||||
model: 'gemini-2.0-flash',
|
||||
url: kGeminiUrl,
|
||||
|
||||
@@ -31,13 +31,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('map getter returns map of providers', () {
|
||||
final provider = AIModelProvider(
|
||||
const provider = AIModelProvider(
|
||||
providerId: ModelAPIProvider.openai,
|
||||
providerName: "OpenAI",
|
||||
models: [const Model(id: "gpt-4", name: "GPT-4")],
|
||||
models: [Model(id: "gpt-4", name: "GPT-4")],
|
||||
);
|
||||
|
||||
final available = AvailableModels(
|
||||
const available = AvailableModels(
|
||||
version: 1.0,
|
||||
modelProviders: [provider],
|
||||
);
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
providerName: "OpenAI",
|
||||
);
|
||||
|
||||
const model = const Model(id: "gpt-4", name: "GPT-4");
|
||||
const model = Model(id: "gpt-4", name: "GPT-4");
|
||||
final req = provider.toAiRequestModel(model: model);
|
||||
|
||||
expect(req?.model, "gpt-4");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:genai/models/available_models.dart';
|
||||
import 'package:genai/utils/model_manager.dart';
|
||||
@@ -11,12 +10,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('fetchInstalledOllamaModels parses response', () async {
|
||||
final body = jsonEncode({
|
||||
"models": [
|
||||
{"model": "mistral", "name": "Mistral"},
|
||||
{"model": "llama2", "name": "LLaMA 2"},
|
||||
],
|
||||
});
|
||||
final result = await ModelManager.fetchInstalledOllamaModels();
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user