22 lines
562 B
Dart
22 lines
562 B
Dart
import 'dart:async';
|
|
|
|
import 'package:workouttest_util/service/api.dart';
|
|
import 'package:workouttest_util/util/logging.dart';
|
|
|
|
|
|
class OpenAIApi with Logging {
|
|
final APIClient _client = APIClient();
|
|
|
|
Future<String> getOpenAICompletion(String question) async {
|
|
String? response;
|
|
try {
|
|
final body = await _client.post("openai/completion", question);
|
|
response = body;
|
|
} on TimeoutException catch (_) {
|
|
log("Timeout from OpenAI");
|
|
} on Exception catch (e) {
|
|
log(e.toString());
|
|
}
|
|
return response ?? "";
|
|
}
|
|
} |