feat: implement plant identification result card component and initialize backend server infrastructure
This commit is contained in:
@@ -69,6 +69,14 @@ const SEMANTIC_SEARCH_COST = 2;
|
||||
const HEALTH_CHECK_COST = 2;
|
||||
const LOW_CONFIDENCE_REVIEW_THRESHOLD = 0.8;
|
||||
|
||||
let catalogCache = null;
|
||||
|
||||
const getCachedCatalogEntries = async (db) => {
|
||||
if (catalogCache) return catalogCache;
|
||||
catalogCache = await getPlants(db, { limit: 500 });
|
||||
return catalogCache;
|
||||
};
|
||||
|
||||
const DEFAULT_BOOTSTRAP_PLANTS = [
|
||||
{
|
||||
id: '1',
|
||||
@@ -627,18 +635,16 @@ app.post('/v1/scan', async (request, response) => {
|
||||
let modelUsed = null;
|
||||
let modelFallbackCount = 0;
|
||||
|
||||
if (!isGuest(userId)) {
|
||||
creditsCharged += await consumeCreditsWithIdempotency(
|
||||
db,
|
||||
userId,
|
||||
chargeKey('scan-primary', userId, idempotencyKey),
|
||||
SCAN_PRIMARY_COST,
|
||||
);
|
||||
}
|
||||
const [creditResult, accountSnapshot, catalogEntries] = await Promise.all([
|
||||
isGuest(userId)
|
||||
? Promise.resolve(0)
|
||||
: consumeCreditsWithIdempotency(db, userId, chargeKey('scan-primary', userId, idempotencyKey), SCAN_PRIMARY_COST),
|
||||
getAccountSnapshot(db, userId),
|
||||
getCachedCatalogEntries(db),
|
||||
]);
|
||||
creditsCharged += creditResult;
|
||||
|
||||
const accountSnapshot = await getAccountSnapshot(db, userId);
|
||||
const scanPlan = accountSnapshot.plan === 'pro' ? 'pro' : 'free';
|
||||
const catalogEntries = await getPlants(db, { limit: 500 });
|
||||
let result = pickCatalogFallback(catalogEntries, imageUri, false, { silent: true });
|
||||
let usedOpenAi = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user