mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-01-13 19:50:28 +00:00
73 lines
2.0 KiB
Dart
73 lines
2.0 KiB
Dart
// This file is automatically generated, so please do not edit it.
|
||
// @generated by `flutter_rust_bridge`@ 2.11.1.
|
||
|
||
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
||
|
||
import '../frb_generated.dart';
|
||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||
|
||
/// 加载 ONNX 翻译模型
|
||
///
|
||
/// # Arguments
|
||
/// * `model_path` - 模型文件夹路径
|
||
/// * `model_key` - 模型缓存键(用于标识模型,如 "zh-en")
|
||
/// * `quantization_suffix` - 量化后缀(如 "_q4", "_q8",空字符串表示使用默认模型)
|
||
///
|
||
Future<void> loadTranslationModel({
|
||
required String modelPath,
|
||
required String modelKey,
|
||
required String quantizationSuffix,
|
||
}) => RustLib.instance.api.crateApiOrtApiLoadTranslationModel(
|
||
modelPath: modelPath,
|
||
modelKey: modelKey,
|
||
quantizationSuffix: quantizationSuffix,
|
||
);
|
||
|
||
/// 翻译文本
|
||
///
|
||
/// # Arguments
|
||
/// * `model_key` - 模型缓存键(如 "zh-en")
|
||
/// * `text` - 要翻译的文本
|
||
///
|
||
/// # Returns
|
||
/// * `Result<String>` - 翻译后的文本
|
||
Future<String> translateText({
|
||
required String modelKey,
|
||
required String text,
|
||
}) => RustLib.instance.api.crateApiOrtApiTranslateText(
|
||
modelKey: modelKey,
|
||
text: text,
|
||
);
|
||
|
||
/// 批量翻译文本
|
||
///
|
||
/// # Arguments
|
||
/// * `model_key` - 模型缓存键(如 "zh-en")
|
||
/// * `texts` - 要翻译的文本列表
|
||
///
|
||
/// # Returns
|
||
/// * `Result<Vec<String>>` - 翻译后的文本列表
|
||
Future<List<String>> translateTextBatch({
|
||
required String modelKey,
|
||
required List<String> texts,
|
||
}) => RustLib.instance.api.crateApiOrtApiTranslateTextBatch(
|
||
modelKey: modelKey,
|
||
texts: texts,
|
||
);
|
||
|
||
/// 卸载模型
|
||
///
|
||
/// # Arguments
|
||
/// * `model_key` - 模型缓存键(如 "zh-en")
|
||
///
|
||
Future<void> unloadTranslationModel({required String modelKey}) => RustLib
|
||
.instance
|
||
.api
|
||
.crateApiOrtApiUnloadTranslationModel(modelKey: modelKey);
|
||
|
||
/// 清空所有已加载的模型
|
||
///
|
||
/// # Returns
|
||
Future<void> clearAllModels() =>
|
||
RustLib.instance.api.crateApiOrtApiClearAllModels();
|