11/25/1
This commit is contained in:
@@ -59,7 +59,42 @@ class CRUD {
|
||||
{
|
||||
"role": "user",
|
||||
"content":
|
||||
"Extract the desired information from the following passage as json decoded like vin,make,made,color,owner and all you find in this:\n\n$payload"
|
||||
"Extract the desired information from the following passage as json decoded like vin,make,made,year,expiration_date,color,owner,registration_date just in this:\n\n$payload"
|
||||
}
|
||||
],
|
||||
"temperature": 0.9
|
||||
});
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: data,
|
||||
headers: headers,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.body;
|
||||
}
|
||||
return response.statusCode;
|
||||
}
|
||||
|
||||
Future<dynamic> getChatGPT({
|
||||
required String link,
|
||||
required String payload,
|
||||
}) async {
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
var headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization':
|
||||
'Bearer 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'
|
||||
};
|
||||
var data = json.encode({
|
||||
"model": "gpt-3.5-turbo",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content":
|
||||
"Extract the desired information from the following passage as json decoded like vin,make,made,year,expiration_date,color,owner,registration_date just in this:\n\n$payload"
|
||||
}
|
||||
],
|
||||
"temperature": 0.9
|
||||
|
||||
@@ -4,18 +4,21 @@ import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
|
||||
class LlamaAi {
|
||||
Future getExractionData(String input) async {
|
||||
Future<Map> getCarRegistrationData(String input) async {
|
||||
print(true);
|
||||
|
||||
Map exrtatDataFinal = {};
|
||||
String oneLine = input.replaceAll('\n', ' ');
|
||||
var res = await CRUD().getLlama(link: AppLink.llama, payload: oneLine);
|
||||
var decod = jsonDecode(res);
|
||||
// print(decod['choices'][0]['message']['content']);
|
||||
extractDataFromJsonString(decod['choices'][0]['message']['content']);
|
||||
// print(decod);
|
||||
exrtatDataFinal = jsonDecode(
|
||||
extractDataFromJsonString(decod['choices'][0]['message']['content']));
|
||||
// print(jsonEncode(exrtatDataFinal));
|
||||
print(false);
|
||||
return exrtatDataFinal;
|
||||
}
|
||||
|
||||
Map<String, dynamic> extractDataFromJsonString(String jsonString) {
|
||||
String extractDataFromJsonString(String jsonString) {
|
||||
// Remove any leading or trailing whitespace from the string
|
||||
jsonString = jsonString.trim();
|
||||
|
||||
@@ -25,10 +28,11 @@ class LlamaAi {
|
||||
final jsonSubstring = jsonString.substring(startIndex, endIndex + 1);
|
||||
|
||||
// Parse the JSON substring into a Map
|
||||
final jsonData = json.decode(jsonSubstring);
|
||||
final jsonData = jsonDecode(jsonSubstring);
|
||||
|
||||
// Return the extracted data
|
||||
print(jsonData);
|
||||
return jsonData;
|
||||
|
||||
// print(jsonEncode(jsonData));
|
||||
return jsonEncode(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:ride/constant/api_key.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/constant/info.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/env/env.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
@@ -284,9 +286,11 @@ class ScanDocumentsByApi extends GetxController {
|
||||
///
|
||||
|
||||
Future<void> scanDocumentsByApi() async {
|
||||
String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
// String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
// String? visionApi = AK.visionApi;
|
||||
// Pick an image from the camera or gallery
|
||||
image = await imagePicker.pickImage(source: ImageSource.camera);
|
||||
// print(visionApi);
|
||||
image = await imagePicker.pickImage(source: ImageSource.camera); //
|
||||
|
||||
// If no image was picked, return
|
||||
if (image == null) {
|
||||
@@ -295,7 +299,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
|
||||
isLoading = true;
|
||||
update();
|
||||
var headers = {'X-BLOBR-KEY': visionApi.toString()};
|
||||
var headers = {'X-BLOBR-KEY': AK.visionApi};
|
||||
var request = http.MultipartRequest('POST',
|
||||
Uri.parse('https://api.faceonlive.com/j2y3q25y1b6maif1/api/iddoc'));
|
||||
request.files.add(await http.MultipartFile.fromPath('image', image!.path));
|
||||
@@ -399,7 +403,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
|
||||
Map res = {};
|
||||
Future matchFaceApi() async {
|
||||
String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
// String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
imageFace = await imagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
preferredCameraDevice: CameraDevice.front,
|
||||
@@ -411,13 +415,13 @@ class ScanDocumentsByApi extends GetxController {
|
||||
}
|
||||
final imageFile = File(imageFace!.path);
|
||||
// Uint8List imageBytes = await imageFile.readAsBytes();
|
||||
var headers = {'X-BLOBR-KEY': visionApi.toString()};
|
||||
var headers = {'X-BLOBR-KEY': AK.visionApi};
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(
|
||||
'https://api.faceonlive.com/sntzbspfsdupgid1/api/face_compare'));
|
||||
request.files
|
||||
.add(await http.MultipartFile.fromPath('image1', imageFace!.path));
|
||||
.add(await http.MultipartFile.fromPath('image1', imageFile.path));
|
||||
request.files.add(await http.MultipartFile.fromPath('image2', imagePath));
|
||||
request.headers.addAll(headers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user