v1.0.13 openai chat completion
This commit is contained in:
@@ -2,10 +2,10 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:workouttest_util/model/openai.dart';
|
||||
import 'package:workouttest_util/model/openai_chat.dart';
|
||||
import 'package:workouttest_util/service/api.dart';
|
||||
import 'package:workouttest_util/util/logging.dart';
|
||||
|
||||
|
||||
class OpenAIApi with Logging {
|
||||
final APIClient _client = APIClient();
|
||||
|
||||
@@ -13,12 +13,12 @@ class OpenAIApi with Logging {
|
||||
String? response;
|
||||
try {
|
||||
final body = await _client.post("openai/completion", question);
|
||||
response = body;
|
||||
response = body;
|
||||
} on TimeoutException catch (_) {
|
||||
log("Timeout from OpenAI");
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
}
|
||||
return response ?? "";
|
||||
}
|
||||
|
||||
@@ -31,7 +31,20 @@ class OpenAIApi with Logging {
|
||||
log("Timeout from OpenAI");
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
}
|
||||
return response ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getOpenAIChatCompletion(OpenAIChat openai) async {
|
||||
String? response;
|
||||
try {
|
||||
String body = const JsonEncoder().convert(openai.toJson());
|
||||
response = await _client.post("openai/chat_completion", body);
|
||||
} on TimeoutException catch (_) {
|
||||
log("Timeout from OpenAI");
|
||||
} on Exception catch (e) {
|
||||
log(e.toString());
|
||||
}
|
||||
return response ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user