Fix for bad handling of predict response from model isolate

I also went ahead and updated the CIPD dart/language_model version to the latest model version.

Change-Id: I4522209150a90acfba210885316e78381c2aee45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Ari Aye <ariaye@google.com>
This commit is contained in:
Ari Aye 2019-07-29 20:41:35 +00:00
parent d54ab60990
commit db796d5b96
2 changed files with 6 additions and 5 deletions

2
DEPS
View file

@ -406,7 +406,7 @@ deps = {
"packages": [
{
"package": "dart/language_model",
"version": "KB68QHR1SKtopACaf3TFcu9MusRbwWqs0L1m_urGLL4C",
"version": "gABkW8D_-f45it57vQ_ZTKFwev16RcCjvrdTCytEnQgC",
}
],
"dep_type": "cipd",

View file

@ -26,7 +26,7 @@ void entrypoint(SendPort sendPort) {
final port = ReceivePort();
sendPort.send(port.sendPort);
port.listen((message) {
Map<String, dynamic> response = {};
Map<String, Map<String, double>> response = {};
switch (message['method']) {
case 'load':
model = LanguageModel.load(message['args'][0]);
@ -65,13 +65,14 @@ class CompletionRanking {
/// Makes a next-token prediction starting at the completion request
/// cursor and walking back to find previous input tokens.
Future<Map<String, double>> predict(DartCompletionRequest request) {
Future<Map<String, double>> predict(DartCompletionRequest request) async {
final query = constructQuery(request, _LOOKBACK);
if (query == null) {
return Future.value(null);
}
return makeRequest('predict', query);
final response = await makeRequest('predict', query);
return response['data'];
}
/// Transforms [CompletionSuggestion] relevances and
@ -177,7 +178,7 @@ class CompletionRanking {
}
/// Send an RPC to the isolate worker and wait for it to respond.
Future<Map<String, dynamic>> makeRequest(
Future<Map<String, Map<String, double>>> makeRequest(
String method, List<String> args) async {
final port = ReceivePort();
_write.send({