قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ. الخريطة: backend · payment_server · loction_server · ride_server · passenger_server · docker · dashboard · stress_test → الجذر siro_rider → apps/rider siro_driver → apps/driver siro_admin → dashboards/admin siro_service → dashboards/service android_bot → apps/android_bot socialBot → apps/socialBot نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب) لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً: كل ما يلي يصير فرقاً مقروءاً مقابل المصدر. لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز، سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh (ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و dashboards/transit-web). ⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة: 1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر): كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner. 2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist) يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً. 3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع → يجب ضمّ الحزم داخله أسوة بـ apps/rider. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
830 lines
27 KiB
Dart
830 lines
27 KiB
Dart
// import 'dart:convert';
|
|
// import 'dart:io';
|
|
// import 'package:get/get.dart';
|
|
// import 'package:image_cropper/image_cropper.dart';
|
|
// import 'package:image_picker/image_picker.dart';
|
|
// import 'package:http/http.dart' as http;
|
|
// import 'package:image/image.dart' as img;
|
|
// import 'package:path_provider/path_provider.dart';
|
|
|
|
// import '../../constant/api_key.dart';
|
|
// import '../../constant/colors.dart';
|
|
|
|
// class AI extends GetxController {
|
|
// final picker = ImagePicker();
|
|
// Map<String, dynamic> responseMap = {};
|
|
// Map<String, dynamic> responseCarLicenseMap = {};
|
|
// Map<String, dynamic> responseBackCarLicenseMap = {};
|
|
// Map<String, dynamic> responseIdCardeMap = {};
|
|
// bool isloading = false;
|
|
// var image;
|
|
// CroppedFile? croppedFile;
|
|
// DateTime now = DateTime.now();
|
|
// Future<void> pickImage() async {
|
|
// final pickedImage = await picker.pickImage(source: ImageSource.gallery);
|
|
|
|
// if (pickedImage != null) {
|
|
// image = File(pickedImage.path);
|
|
// // Crop the image
|
|
// croppedFile = await ImageCropper().cropImage(
|
|
// sourcePath: image!.path,
|
|
// aspectRatioPresets: [
|
|
// CropAspectRatioPreset.square,
|
|
// CropAspectRatioPreset.ratio3x2,
|
|
// CropAspectRatioPreset.original,
|
|
// CropAspectRatioPreset.ratio4x3,
|
|
// CropAspectRatioPreset.ratio16x9
|
|
// ],
|
|
// uiSettings: [
|
|
// AndroidUiSettings(
|
|
// toolbarTitle: 'Cropper'.tr,
|
|
// toolbarColor: AppColor.blueColor,
|
|
// toolbarWidgetColor: AppColor.yellowColor,
|
|
// initAspectRatio: CropAspectRatioPreset.original,
|
|
// lockAspectRatio: false),
|
|
// IOSUiSettings(
|
|
// title: 'Cropper'.tr,
|
|
// ),
|
|
// ],
|
|
// );
|
|
// // image = croppedFile;
|
|
|
|
// // Resize the image
|
|
// final rawImage =
|
|
// img.decodeImage(File(croppedFile!.path).readAsBytesSync());
|
|
// final resizedImage =
|
|
// img.copyResize(rawImage!, width: 800); // Adjust the width as needed
|
|
|
|
// final appDir = await getTemporaryDirectory();
|
|
// final resizedImagePath = '${appDir.path}/resized_image.jpg';
|
|
|
|
// final resizedImageFile = File(resizedImagePath);
|
|
// resizedImageFile.writeAsBytesSync(
|
|
// img.encodeJpg(resizedImage)); // Save the resized image as JPEG
|
|
|
|
// image = resizedImageFile;
|
|
// update();
|
|
// }
|
|
// }
|
|
|
|
// Future<void> generateContent() async {
|
|
// await pickImage();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// 'write json for all data as first name ,last name,dob,licenseID,expiration date,issued date asdress class type ,output json type',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> geminiAiExtraction(String prompt, payload) async {
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// // {
|
|
// // 'inlineData': {
|
|
// // 'mimeType': 'image/jpeg',
|
|
// // 'data': imageData,
|
|
// // },
|
|
// // },
|
|
// {
|
|
// 'text':
|
|
// "Extract the desired information from the following passage as json decoded like $prompt .and look for this instruction first name in line 3or 2 ,fullname in line 4 from it written left to right but you modify it rtl,address in line 5 it written left to right but you modify it rtl and 6,dob,nationalid in the last line as just in this:\n\n$payload"
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safety_settings': [
|
|
// {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
|
|
// {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
|
|
// {
|
|
// "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
// "threshold": "BLOCK_NONE"
|
|
// },
|
|
// {
|
|
// "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
// "threshold": "BLOCK_NONE"
|
|
// },
|
|
// ]
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// // 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=AIzaSyCyoLcSkDzK5_SMe00nhut56SSXWPR074w'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result = responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> getDriverLicenseJordanContent() async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// 'write json for all data as first name ,last name,dob,id ,expiration date,issued date asdress class type,age in years ,output json type in arabic value and stay engish key and make date format like YYYY-MM-DD , for name please extract name in arabic in Name in json plus first_name ',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> getCarLicenseJordanContent() async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// '''Extract the following information from the front face of the Jordanian ID card:
|
|
// Name
|
|
// National ID number
|
|
// Gender
|
|
// Date of birth
|
|
// Output the extracted information in the following JSON format''',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// // 'https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:streamGenerateContent'),
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseCarLicenseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> jordanID() async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// '''Extract the following information from the front face of the Jordanian ID card:
|
|
// Name
|
|
// National ID number
|
|
// Gender
|
|
// Date of birth
|
|
// Output the extracted information in the following JSON format''',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseCarLicenseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> carLicenseJordan() async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// '''Extract the following information from the front face of the car license card in Jordan:
|
|
|
|
// * name
|
|
// * Address
|
|
// * Vehicle type
|
|
// * car_kind
|
|
// * car_color
|
|
// * Vehicle category
|
|
// * car_year
|
|
// * car_plate
|
|
// * Registration type
|
|
// * Usage type
|
|
// * expire_date_of_license
|
|
|
|
// Output the extracted information in the following JSON formate and make date format like YYYY-MM-DD''',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro-vision-latest:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseCarLicenseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future getTextFromCard(String prompt) async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text': prompt,
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// "temperature": 1,
|
|
// "topK": 32,
|
|
// "topP": 0.1,
|
|
// "maxOutputTokens": 4096,
|
|
// "stopSequences": []
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro-vision-latest:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseBackCarLicenseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> generateBackCarLicenseJordanContent() async {
|
|
// await pickImage();
|
|
// isloading = true;
|
|
// update();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// 'write json output from extracting car license back face for these key ,vin,fuelType,passengerType,curbWeight,insuranceCompany,policyNumber,notes,insuranceType and output it json .dont add data else this image',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 343,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
// isloading = false;
|
|
// update();
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// responseBackCarLicenseMap = jsonDecode(jsonString);
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// Future<void> getFromCarRegistration() async {
|
|
// await pickImage();
|
|
// if (image != null) {
|
|
// final imageBytes = await image.readAsBytes();
|
|
// final imageData = base64Encode(imageBytes);
|
|
|
|
// var requestBody = jsonEncode({
|
|
// 'contents': [
|
|
// {
|
|
// 'parts': [
|
|
// {
|
|
// 'inlineData': {
|
|
// 'mimeType': 'image/jpeg',
|
|
// 'data': imageData,
|
|
// },
|
|
// },
|
|
// {
|
|
// 'text':
|
|
// 'write output json from image for[ vin, make, model, year, expiration_date, color, owner, registration_date ],output json type ',
|
|
// },
|
|
// ],
|
|
// },
|
|
// ],
|
|
// 'generationConfig': {
|
|
// 'temperature': 0.4,
|
|
// 'topK': 32,
|
|
// 'topP': 1,
|
|
// 'maxOutputTokens': 4096,
|
|
// 'stopSequences': [],
|
|
// },
|
|
// 'safetySettings': [
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HARASSMENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_HATE_SPEECH',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// {
|
|
// 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
// 'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
|
|
// },
|
|
// ],
|
|
// });
|
|
|
|
// final response = await http.post(
|
|
// Uri.parse(
|
|
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
|
// headers: {'Content-Type': 'application/json'},
|
|
// body: requestBody,
|
|
// );
|
|
|
|
// if (response.statusCode == 200) {
|
|
// var responseData = jsonDecode(response.body);
|
|
// // Process the responseData as needed
|
|
// var result =
|
|
// responseData['candidates'][0]['content']['parts'][0]['text'];
|
|
// RegExp regex = RegExp(r"```json([^`]*)```");
|
|
// String? jsonString =
|
|
// regex.firstMatch(responseData.toString())?.group(1)?.trim();
|
|
|
|
// if (jsonString != null) {
|
|
// // Convert the JSON object to a String
|
|
// jsonString = jsonEncode(json.decode(jsonString));
|
|
// } else {
|
|
// }
|
|
|
|
// // Rest of your code...
|
|
// } else {
|
|
// }
|
|
// } else {
|
|
// }
|
|
// }
|
|
|
|
// @override
|
|
// void onInit() {
|
|
// // generateContent();
|
|
// super.onInit();
|
|
// }
|
|
// }
|