intermediate
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:langchain_openai/langchain_openai.dart';
|
||||
import 'package:riverpod/riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'models.g.dart';
|
||||
|
||||
// @Riverpod(keepAlive: true)
|
||||
// ChatOpenAI summarizerModel(Ref ref) {
|
||||
// final openaiApiKey = Platform.environment['OPENAI_API_KEY'];
|
||||
// return ChatOpenAI(
|
||||
// apiKey: openaiApiKey,
|
||||
// baseUrl: 'https://api.together.xyz/v1',
|
||||
// defaultOptions: const ChatOpenAIOptions(model: 'deepseek-ai/DeepSeek-V3'),
|
||||
// );
|
||||
// }
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
ChatOpenAI chatModel(Ref ref) {
|
||||
final openaiApiKey = 'FfTBKW1t5dOOXVoiaF2hbXPAHiz3fvfy';
|
||||
return ChatOpenAI(
|
||||
apiKey: openaiApiKey,
|
||||
baseUrl: 'https://api.deepinfra.com/v1/openai',
|
||||
defaultOptions: const ChatOpenAIOptions(
|
||||
model: 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
OpenAIEmbeddings embeddingModel(Ref ref) {
|
||||
final openaiApiKey = 'FfTBKW1t5dOOXVoiaF2hbXPAHiz3fvfy';
|
||||
return OpenAIEmbeddings(
|
||||
apiKey: openaiApiKey,
|
||||
baseUrl: 'https://api.deepinfra.com/v1/openai',
|
||||
model: 'BAAI/bge-m3',
|
||||
);
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
int embeddingDimensions(Ref ref) => 1024;
|
||||
@@ -0,0 +1,61 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'models.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$chatModelHash() => r'e7538b9f0dd43ea64953164c5402e76fde96f5e9';
|
||||
|
||||
/// See also [chatModel].
|
||||
@ProviderFor(chatModel)
|
||||
final chatModelProvider = Provider<ChatOpenAI>.internal(
|
||||
chatModel,
|
||||
name: r'chatModelProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$chatModelHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef ChatModelRef = ProviderRef<ChatOpenAI>;
|
||||
String _$embeddingModelHash() => r'5d65c75df195a26adefac5a75f0e8f6b0f1b8590';
|
||||
|
||||
/// See also [embeddingModel].
|
||||
@ProviderFor(embeddingModel)
|
||||
final embeddingModelProvider = Provider<OpenAIEmbeddings>.internal(
|
||||
embeddingModel,
|
||||
name: r'embeddingModelProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$embeddingModelHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef EmbeddingModelRef = ProviderRef<OpenAIEmbeddings>;
|
||||
String _$embeddingDimensionsHash() =>
|
||||
r'e34f544a18a7e2bd6a479b21f2016b0c0e2ba96c';
|
||||
|
||||
/// See also [embeddingDimensions].
|
||||
@ProviderFor(embeddingDimensions)
|
||||
final embeddingDimensionsProvider = Provider<int>.internal(
|
||||
embeddingDimensions,
|
||||
name: r'embeddingDimensionsProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$embeddingDimensionsHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef EmbeddingDimensionsRef = ProviderRef<int>;
|
||||
// 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
|
||||
@@ -6,7 +6,9 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'providers.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
GoRouter router(Ref ref) => GoRouter(
|
||||
debugLogDiagnostics: true,
|
||||
routes: $appRoutes,
|
||||
);
|
||||
GoRouter router(Ref ref) {
|
||||
return GoRouter(
|
||||
debugLogDiagnostics: true,
|
||||
routes: $appRoutes,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'providers.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$routerHash() => r'dcafae2924a2ad3d5d836c6756d2e4a4ead36b4e';
|
||||
String _$routerHash() => r'25fc899b87c080600f6e1d87d510db333378bdfd';
|
||||
|
||||
/// See also [router].
|
||||
@ProviderFor(router)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:lensai/core/routing/dialog_page.dart';
|
||||
import 'package:lensai/data/models/web_page_info.dart';
|
||||
import 'package:lensai/features/about/presentation/screens/about.dart';
|
||||
import 'package:lensai/features/bangs/presentation/screens/categories.dart';
|
||||
import 'package:lensai/features/bangs/presentation/screens/list.dart';
|
||||
@@ -8,10 +9,12 @@ import 'package:lensai/features/bangs/presentation/screens/search.dart';
|
||||
import 'package:lensai/features/chat_archive/presentation/screens/detail.dart';
|
||||
import 'package:lensai/features/chat_archive/presentation/screens/list.dart';
|
||||
import 'package:lensai/features/chat_archive/presentation/screens/search.dart';
|
||||
import 'package:lensai/features/geckoview/features/browser/presentation/dialogs/web_page_dialog.dart';
|
||||
import 'package:lensai/features/geckoview/features/browser/presentation/screens/browser.dart';
|
||||
import 'package:lensai/features/geckoview/features/tabs/presentation/screens/container_list.dart';
|
||||
import 'package:lensai/features/search/presentation/screens/search.dart';
|
||||
import 'package:lensai/features/settings/presentation/screens/settings.dart';
|
||||
import 'package:lensai/features/user/presentation/screens/auth.dart';
|
||||
|
||||
part 'routes.g.dart';
|
||||
|
||||
@@ -19,10 +22,18 @@ part 'routes.g.dart';
|
||||
name: 'BrowserRoute',
|
||||
path: '/',
|
||||
routes: [
|
||||
TypedGoRoute<WebPageRoute>(
|
||||
name: 'WebPageRoute',
|
||||
path: 'page/:url',
|
||||
),
|
||||
TypedGoRoute<AboutRoute>(
|
||||
name: 'AboutRoute',
|
||||
path: 'about',
|
||||
),
|
||||
TypedGoRoute<UserAuthRoute>(
|
||||
name: 'UserAuthRoute',
|
||||
path: 'userAuth',
|
||||
),
|
||||
TypedGoRoute<SearchRoute>(
|
||||
name: 'SearchRoute',
|
||||
path: 'search/:searchText',
|
||||
@@ -60,6 +71,22 @@ class BrowserRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class WebPageRoute extends GoRouteData {
|
||||
final String url;
|
||||
|
||||
const WebPageRoute({required this.url});
|
||||
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(
|
||||
builder: (_) => WebPageDialog(
|
||||
url: Uri.parse(url),
|
||||
precachedInfo: state.extra as WebPageInfo?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AboutRoute extends GoRouteData {
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
@@ -67,6 +94,13 @@ class AboutRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class UserAuthRoute extends GoRouteData {
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(builder: (_) => const UserAuthScreen());
|
||||
}
|
||||
}
|
||||
|
||||
class SearchRoute extends GoRouteData {
|
||||
static const String emptySearchText = ' ';
|
||||
|
||||
|
||||
@@ -17,11 +17,21 @@ RouteBase get $browserRoute => GoRouteData.$route(
|
||||
name: 'BrowserRoute',
|
||||
factory: $BrowserRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'page/:url',
|
||||
name: 'WebPageRoute',
|
||||
factory: $WebPageRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'about',
|
||||
name: 'AboutRoute',
|
||||
factory: $AboutRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'userAuth',
|
||||
name: 'UserAuthRoute',
|
||||
factory: $UserAuthRouteExtension._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'search/:searchText',
|
||||
name: 'SearchRoute',
|
||||
@@ -76,6 +86,25 @@ extension $BrowserRouteExtension on BrowserRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $WebPageRouteExtension on WebPageRoute {
|
||||
static WebPageRoute _fromState(GoRouterState state) => WebPageRoute(
|
||||
url: state.pathParameters['url']!,
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/page/${Uri.encodeComponent(url)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $AboutRouteExtension on AboutRoute {
|
||||
static AboutRoute _fromState(GoRouterState state) => AboutRoute();
|
||||
|
||||
@@ -93,6 +122,23 @@ extension $AboutRouteExtension on AboutRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $UserAuthRouteExtension on UserAuthRoute {
|
||||
static UserAuthRoute _fromState(GoRouterState state) => UserAuthRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/userAuth',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $SearchRouteExtension on SearchRoute {
|
||||
static SearchRoute _fromState(GoRouterState state) => SearchRoute(
|
||||
searchText:
|
||||
|
||||
Reference in New Issue
Block a user