Update project
This commit is contained in:
58
lib/service/ai_service/api_service.dart
Normal file
58
lib/service/ai_service/api_service.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class GroqService {
|
||||
static const String _apiKey = 'YOUR_API_KEY';
|
||||
|
||||
static Future<String> fetchIngredients(String query) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('https://api.groq.com/openai/v1/chat/completions'),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $_apiKey',
|
||||
},
|
||||
body: jsonEncode({
|
||||
'model': 'llama-3.1-8b-instant',
|
||||
'max_tokens': 600,
|
||||
'messages': [
|
||||
{
|
||||
'role': 'system',
|
||||
'content':
|
||||
'Return ONLY JSON array of grocery items...'
|
||||
},
|
||||
{'role': 'user', 'content': query}
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
final data = jsonDecode(res.body);
|
||||
return data['choices'][0]['message']['content'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AiSearchService {
|
||||
static const String baseUrl =
|
||||
'http://10.0.2.2:8000/find-ingredients';
|
||||
|
||||
Future<Map<String, dynamic>> search(String query) async {
|
||||
final response = await http.post(
|
||||
Uri.parse(baseUrl),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: jsonEncode({
|
||||
"user_input": query,
|
||||
"customer_id": 6060,
|
||||
"latitude": 11.0050728,
|
||||
"longitude": 76.9508513
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return jsonDecode(response.body);
|
||||
}
|
||||
|
||||
throw Exception("Failed to load results");
|
||||
}
|
||||
}
|
||||
0
lib/service/ai_service/product_service.dart
Normal file
0
lib/service/ai_service/product_service.dart
Normal file
0
lib/service/ai_service/store_service.dart
Normal file
0
lib/service/ai_service/store_service.dart
Normal file
28
lib/service/firebase_analytics/analytics_service.dart
Normal file
28
lib/service/firebase_analytics/analytics_service.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
|
||||
class AnalyticsService {
|
||||
static final FirebaseAnalytics analytics =
|
||||
FirebaseAnalytics.instance;
|
||||
|
||||
static Future<void> logScreenView(String screenName) async {
|
||||
await analytics.logScreenView(
|
||||
screenName: screenName,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> logLogin(String method) async {
|
||||
await analytics.logLogin(
|
||||
loginMethod: method,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> logEvent(
|
||||
String name, {
|
||||
Map<String, Object>? parameters,
|
||||
}) async {
|
||||
await analytics.logEvent(
|
||||
name: name,
|
||||
parameters: parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user