Skip to content

Commit

Permalink
fix entry
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Feb 10, 2025
1 parent 4dccaea commit fb9830a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';

Expand Down Expand Up @@ -42,7 +41,7 @@ class _LlamaAppState extends State<LlamaApp> {
throw Exception('File does not exist');
}

final llamaCpp = LlamaNative(
final llamaCpp = LlamaIsolated(
modelParams: ModelParams(
path: result.files.single.path!
),
Expand Down
10 changes: 5 additions & 5 deletions lib/src/context_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class ContextParams {
nSeqMax: map['nSeqMax'],
nThreads: map['nThreads'],
nThreadsBatch: map['nThreadsBatch'],
ropeScalingType: RopeScalingType.fromString(map['ropeScalingType']),
poolingType: PoolingType.fromString(map['poolingType']),
attentionType: AttentionType.fromString(map['attentionType']),
ropeScalingType: map['ropeScalingType'] != null ? RopeScalingType.fromString(map['ropeScalingType']) : null,
poolingType: map['poolingType'] != null ? PoolingType.fromString(map['poolingType']) : null,
attentionType: map['attentionType'] != null ? AttentionType.fromString(map['attentionType']) : null,
ropeFrequencyBase: map['ropeFrequencyBase'],
ropeFrequencyScale: map['ropeFrequencyScale'],
yarnExtrapolationFactor: map['yarnExtrapolationFactor'],
Expand All @@ -115,8 +115,8 @@ class ContextParams {
yarnBetaSlow: map['yarnBetaSlow'],
yarnOriginalContext: map['yarnOriginalContext'],
defragmentationThreshold: map['defragmentationThreshold'],
typeK: GgmlType.fromString(map['typeK']),
typeV: GgmlType.fromString(map['typeV']),
typeK: map['typeK'] != null ? GgmlType.fromString(map['typeK']) : null,
typeV: map['typeV'] != null ? GgmlType.fromString(map['typeV']) : null,
embeddings: map['embeddings'],
offloadKqv: map['offloadKqv'],
flashAttention: map['flashAttention'],
Expand Down
2 changes: 1 addition & 1 deletion lib/src/llama_isolate_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LlamaIsolateEntry {
}
}
catch (e) {
sendPort.send((message: e.toString()));
log('LlamaIsolateEntry: $e');
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/src/llama_isolated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class LlamaIsolated implements Llama {
_initialized.complete();
}
else if (data == null) {
print('LlamaIsolated: stopping');
_responseController.close();
break;
}
Expand All @@ -62,13 +63,10 @@ class LlamaIsolated implements Llama {

messages.add(ChatMessage(
role: 'assistant',
content: ''
content: await _responseController.stream.first
));

await for (final message in _responseController.stream) {
messages.last.content += message;
_responseController.close();
}
_responseController.close();

return messages.last.content;
}
Expand Down

0 comments on commit fb9830a

Please sign in to comment.