increase min sdk and apply new formatter
This commit is contained in:
@@ -22,20 +22,17 @@ class KagiAutosuggestService extends _$KagiAutosuggestService
|
||||
|
||||
@override
|
||||
Future<Result<List<String>>> getSuggestions(String query) async {
|
||||
return Result.fromAsync(
|
||||
() async {
|
||||
final response = await _client
|
||||
.get(_baseUrl.replace(queryParameters: {'q': query}))
|
||||
.timeout(const Duration(seconds: 5));
|
||||
return Result.fromAsync(() async {
|
||||
final response = await _client
|
||||
.get(_baseUrl.replace(queryParameters: {'q': query}))
|
||||
.timeout(const Duration(seconds: 5));
|
||||
|
||||
final results = jsonDecode(utf8.decode(response.bodyBytes)) as List;
|
||||
return switch (results.last) {
|
||||
final String result => [result],
|
||||
final List resultList => resultList.cast(),
|
||||
_ => []
|
||||
};
|
||||
},
|
||||
exceptionHandler: handleHttpError,
|
||||
);
|
||||
final results = jsonDecode(utf8.decode(response.bodyBytes)) as List;
|
||||
return switch (results.last) {
|
||||
final String result => [result],
|
||||
final List resultList => resultList.cast(),
|
||||
_ => [],
|
||||
};
|
||||
}, exceptionHandler: handleHttpError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,15 @@ String _$kagiAutosuggestServiceHash() =>
|
||||
@ProviderFor(KagiAutosuggestService)
|
||||
final kagiAutosuggestServiceProvider =
|
||||
NotifierProvider<KagiAutosuggestService, void>.internal(
|
||||
KagiAutosuggestService.new,
|
||||
name: r'kagiAutosuggestServiceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiAutosuggestServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
KagiAutosuggestService.new,
|
||||
name: r'kagiAutosuggestServiceProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiAutosuggestServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$KagiAutosuggestService = Notifier<void>;
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
@@ -12,14 +12,15 @@ String _$kagiChatServiceHash() => r'a112b70b42fe9d650c9d4dc643bf965ddce7bfa6';
|
||||
@ProviderFor(KagiChatService)
|
||||
final kagiChatServiceProvider =
|
||||
NotifierProvider<KagiChatService, void>.internal(
|
||||
KagiChatService.new,
|
||||
name: r'kagiChatServiceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiChatServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
KagiChatService.new,
|
||||
name: r'kagiChatServiceProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiChatServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$KagiChatService = Notifier<void>;
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
@@ -13,14 +13,15 @@ String _$kagiSessionServiceHash() =>
|
||||
@ProviderFor(KagiSessionService)
|
||||
final kagiSessionServiceProvider =
|
||||
AutoDisposeNotifierProvider<KagiSessionService, void>.internal(
|
||||
KagiSessionService.new,
|
||||
name: r'kagiSessionServiceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiSessionServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
KagiSessionService.new,
|
||||
name: r'kagiSessionServiceProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$kagiSessionServiceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$KagiSessionService = AutoDisposeNotifier<void>;
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
@@ -32,29 +32,29 @@ class SearchSuggestionsRepository extends _$SearchSuggestionsRepository {
|
||||
|
||||
return _queryStreamController.stream
|
||||
.sampleTime(const Duration(milliseconds: 100))
|
||||
.switchMap<List<String>>(
|
||||
(query) {
|
||||
if (query.isEmpty) {
|
||||
return Stream.value([]);
|
||||
}
|
||||
.switchMap<List<String>>((query) {
|
||||
if (query.isEmpty) {
|
||||
return Stream.value([]);
|
||||
}
|
||||
|
||||
final cached = _cache.get(query);
|
||||
if (cached != null) {
|
||||
return Stream.value(cached);
|
||||
}
|
||||
final cached = _cache.get(query);
|
||||
if (cached != null) {
|
||||
return Stream.value(cached);
|
||||
}
|
||||
|
||||
return suggestionsProvider
|
||||
// ignore: discarded_futures
|
||||
.getSuggestions(query)
|
||||
// ignore: discarded_futures
|
||||
.then((result) {
|
||||
result.onSuccess((result) {
|
||||
_cache.set(query, result);
|
||||
});
|
||||
return suggestionsProvider
|
||||
// ignore: discarded_futures
|
||||
.getSuggestions(query)
|
||||
// ignore: discarded_futures
|
||||
.then((result) {
|
||||
result.onSuccess((result) {
|
||||
_cache.set(query, result);
|
||||
});
|
||||
|
||||
return result.value;
|
||||
}).asStream();
|
||||
},
|
||||
).asBroadcastStream();
|
||||
return result.value;
|
||||
})
|
||||
.asStream();
|
||||
})
|
||||
.asBroadcastStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,18 +53,14 @@ class SearchSuggestionsRepositoryFamily
|
||||
SearchSuggestionsRepositoryProvider call(
|
||||
ISearchSuggestionProvider suggestionsProvider,
|
||||
) {
|
||||
return SearchSuggestionsRepositoryProvider(
|
||||
suggestionsProvider,
|
||||
);
|
||||
return SearchSuggestionsRepositoryProvider(suggestionsProvider);
|
||||
}
|
||||
|
||||
@override
|
||||
SearchSuggestionsRepositoryProvider getProviderOverride(
|
||||
covariant SearchSuggestionsRepositoryProvider provider,
|
||||
) {
|
||||
return call(
|
||||
provider.suggestionsProvider,
|
||||
);
|
||||
return call(provider.suggestionsProvider);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
@@ -83,25 +79,30 @@ class SearchSuggestionsRepositoryFamily
|
||||
}
|
||||
|
||||
/// See also [SearchSuggestionsRepository].
|
||||
class SearchSuggestionsRepositoryProvider extends NotifierProviderImpl<
|
||||
SearchSuggestionsRepository, Raw<Stream<List<String>>>> {
|
||||
class SearchSuggestionsRepositoryProvider
|
||||
extends
|
||||
NotifierProviderImpl<
|
||||
SearchSuggestionsRepository,
|
||||
Raw<Stream<List<String>>>
|
||||
> {
|
||||
/// See also [SearchSuggestionsRepository].
|
||||
SearchSuggestionsRepositoryProvider(
|
||||
ISearchSuggestionProvider suggestionsProvider,
|
||||
) : this._internal(
|
||||
() => SearchSuggestionsRepository()
|
||||
..suggestionsProvider = suggestionsProvider,
|
||||
from: searchSuggestionsRepositoryProvider,
|
||||
name: r'searchSuggestionsRepositoryProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$searchSuggestionsRepositoryHash,
|
||||
dependencies: SearchSuggestionsRepositoryFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SearchSuggestionsRepositoryFamily._allTransitiveDependencies,
|
||||
suggestionsProvider: suggestionsProvider,
|
||||
);
|
||||
() =>
|
||||
SearchSuggestionsRepository()
|
||||
..suggestionsProvider = suggestionsProvider,
|
||||
from: searchSuggestionsRepositoryProvider,
|
||||
name: r'searchSuggestionsRepositoryProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$searchSuggestionsRepositoryHash,
|
||||
dependencies: SearchSuggestionsRepositoryFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SearchSuggestionsRepositoryFamily._allTransitiveDependencies,
|
||||
suggestionsProvider: suggestionsProvider,
|
||||
);
|
||||
|
||||
SearchSuggestionsRepositoryProvider._internal(
|
||||
super._createNotifier, {
|
||||
@@ -119,9 +120,7 @@ class SearchSuggestionsRepositoryProvider extends NotifierProviderImpl<
|
||||
Raw<Stream<List<String>>> runNotifierBuild(
|
||||
covariant SearchSuggestionsRepository notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
suggestionsProvider,
|
||||
);
|
||||
return notifier.build(suggestionsProvider);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -141,8 +140,11 @@ class SearchSuggestionsRepositoryProvider extends NotifierProviderImpl<
|
||||
}
|
||||
|
||||
@override
|
||||
NotifierProviderElement<SearchSuggestionsRepository,
|
||||
Raw<Stream<List<String>>>> createElement() {
|
||||
NotifierProviderElement<
|
||||
SearchSuggestionsRepository,
|
||||
Raw<Stream<List<String>>>
|
||||
>
|
||||
createElement() {
|
||||
return _SearchSuggestionsRepositoryProviderElement(this);
|
||||
}
|
||||
|
||||
@@ -170,13 +172,18 @@ mixin SearchSuggestionsRepositoryRef
|
||||
}
|
||||
|
||||
class _SearchSuggestionsRepositoryProviderElement
|
||||
extends NotifierProviderElement<SearchSuggestionsRepository,
|
||||
Raw<Stream<List<String>>>> with SearchSuggestionsRepositoryRef {
|
||||
extends
|
||||
NotifierProviderElement<
|
||||
SearchSuggestionsRepository,
|
||||
Raw<Stream<List<String>>>
|
||||
>
|
||||
with SearchSuggestionsRepositoryRef {
|
||||
_SearchSuggestionsRepositoryProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
ISearchSuggestionProvider get suggestionsProvider =>
|
||||
(origin as SearchSuggestionsRepositoryProvider).suggestionsProvider;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
|
||||
@@ -60,8 +60,9 @@ class SummarizeTab extends HookConsumerWidget {
|
||||
|
||||
final formKey = useMemoized(() => GlobalKey<FormState>());
|
||||
final selectedMode = useState(SummarizerMode.keyMoments);
|
||||
final textController =
|
||||
useTextEditingController(text: sharedContent?.toString());
|
||||
final textController = useTextEditingController(
|
||||
text: sharedContent?.toString(),
|
||||
);
|
||||
|
||||
return Form(
|
||||
key: formKey,
|
||||
@@ -86,71 +87,63 @@ class SummarizeTab extends HookConsumerWidget {
|
||||
selectedMode.value = value.first;
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
...switch (sharedContent) {
|
||||
SharedUrl() => [
|
||||
_InputField(controller: textController),
|
||||
HookBuilder(
|
||||
builder: (context) {
|
||||
final url =
|
||||
useState(uri_parser.tryParseUrl(textController.text));
|
||||
useEffect(
|
||||
() {
|
||||
Timer? timer;
|
||||
void debounce() {
|
||||
timer?.cancel();
|
||||
timer = Timer(const Duration(milliseconds: 250), () {
|
||||
url.value =
|
||||
uri_parser.tryParseUrl(textController.text);
|
||||
});
|
||||
}
|
||||
_InputField(controller: textController),
|
||||
HookBuilder(
|
||||
builder: (context) {
|
||||
final url = useState(
|
||||
uri_parser.tryParseUrl(textController.text),
|
||||
);
|
||||
useEffect(() {
|
||||
Timer? timer;
|
||||
void debounce() {
|
||||
timer?.cancel();
|
||||
timer = Timer(const Duration(milliseconds: 250), () {
|
||||
url.value = uri_parser.tryParseUrl(textController.text);
|
||||
});
|
||||
}
|
||||
|
||||
textController.addListener(debounce);
|
||||
return () => textController.removeListener(debounce);
|
||||
},
|
||||
[textController],
|
||||
);
|
||||
textController.addListener(debounce);
|
||||
return () => textController.removeListener(debounce);
|
||||
}, [textController]);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (url.value != null) WebsiteTitleTile(url.value!),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
],
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (url.value != null) WebsiteTitleTile(url.value!),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
SharedText() || null => [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () async {
|
||||
final pickResult = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
);
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () async {
|
||||
final pickResult = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
);
|
||||
|
||||
if (pickResult?.files.first.path
|
||||
case final String filePath) {
|
||||
final content = await PDFDoc.fromPath(filePath)
|
||||
.then((doc) => doc.text);
|
||||
textController.text = content;
|
||||
}
|
||||
},
|
||||
icon: const Icon(MdiIcons.fileUpload),
|
||||
label: const Text('Read PDF document'),
|
||||
),
|
||||
if (pickResult?.files.first.path
|
||||
case final String filePath) {
|
||||
final content = await PDFDoc.fromPath(
|
||||
filePath,
|
||||
).then((doc) => doc.text);
|
||||
textController.text = content;
|
||||
}
|
||||
},
|
||||
icon: const Icon(MdiIcons.fileUpload),
|
||||
label: const Text('Read PDF document'),
|
||||
),
|
||||
_InputField(controller: textController),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
_InputField(controller: textController),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
},
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
|
||||
@@ -8,43 +8,35 @@ Uri assistantUri({
|
||||
required AssistantMode assistantMode,
|
||||
ResearchVariant? researchVariant,
|
||||
ChatModel? chatModel,
|
||||
}) =>
|
||||
_baseUrl.replace(
|
||||
pathSegments: [
|
||||
'assistant',
|
||||
],
|
||||
queryParameters: {
|
||||
'mode': assistantMode.value.toString(),
|
||||
'q': prompt,
|
||||
...switch (assistantMode) {
|
||||
AssistantMode.research => {
|
||||
'sub_mode': researchVariant!.value.toString(),
|
||||
},
|
||||
AssistantMode.code => {},
|
||||
AssistantMode.chat => {
|
||||
'sub_mode': chatModel!.value.toString(),
|
||||
},
|
||||
AssistantMode.custom => {},
|
||||
},
|
||||
},
|
||||
);
|
||||
}) => _baseUrl.replace(
|
||||
pathSegments: ['assistant'],
|
||||
queryParameters: {
|
||||
'mode': assistantMode.value.toString(),
|
||||
'q': prompt,
|
||||
...switch (assistantMode) {
|
||||
AssistantMode.research => {'sub_mode': researchVariant!.value.toString()},
|
||||
AssistantMode.code => {},
|
||||
AssistantMode.chat => {'sub_mode': chatModel!.value.toString()},
|
||||
AssistantMode.custom => {},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Uri summarizerUri({
|
||||
required SharedContent document,
|
||||
required SummarizerMode mode,
|
||||
}) =>
|
||||
_baseUrl.replace(
|
||||
pathSegments: [
|
||||
'summarizer',
|
||||
//TODO: check if really necessary
|
||||
'index.html',
|
||||
],
|
||||
queryParameters: {
|
||||
'summary': mode.value,
|
||||
if (document case SharedUrl(url: final url)) 'url': url.toString(),
|
||||
},
|
||||
fragment: switch (document) {
|
||||
SharedText(text: final text) => text,
|
||||
_ => null,
|
||||
},
|
||||
);
|
||||
}) => _baseUrl.replace(
|
||||
pathSegments: [
|
||||
'summarizer',
|
||||
//TODO: check if really necessary
|
||||
'index.html',
|
||||
],
|
||||
queryParameters: {
|
||||
'summary': mode.value,
|
||||
if (document case SharedUrl(url: final url)) 'url': url.toString(),
|
||||
},
|
||||
fragment: switch (document) {
|
||||
SharedText(text: final text) => text,
|
||||
_ => null,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user