v1.0.7 openai with model name and temperature

This commit is contained in:
Tibor Bossanyi
2023-02-19 23:22:36 +01:00
parent 56ada3c774
commit cb90c3d68a
9 changed files with 70 additions and 22 deletions
+15
View File
@@ -1,5 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:workouttest_util/model/openai.dart';
import 'package:workouttest_util/service/api.dart';
import 'package:workouttest_util/util/logging.dart';
@@ -19,4 +21,17 @@ class OpenAIApi with Logging {
}
return response ?? "";
}
Future<String> getOpenAICompletionWithModel(OpenAI openai) async {
String? response;
try {
String body = const JsonEncoder().convert(openai.toJson());
response = await _client.post("openai/completion_with_model", body);
} on TimeoutException catch (_) {
log("Timeout from OpenAI");
} on Exception catch (e) {
log(e.toString());
}
return response ?? "";
}
}