diff --git a/src/app/animals/page.tsx b/src/app/animals/page.tsx
index e0e4351..545f472 100644
--- a/src/app/animals/page.tsx
+++ b/src/app/animals/page.tsx
@@ -6,32 +6,7 @@ import { useState, useEffect } from 'react'
import { MapPin } from 'lucide-react'
import { fetchAnimalRecords } from '../../services/laconicQueryService'
import Navigation from '../../components/Navigation'
-
-interface AnimalRecord {
- id: string
- mainObject: string
- location: {
- latitude: number
- longitude: number
- }
- description: string
- imageUrl: string
- species: string
- // Records from Laconic Registry use `attributes` to store the content
- // and have a separate creation timestamp
- attributes?: {
- mainObject: string
- location: {
- latitude: number
- longitude: number
- }
- description: string
- imageUrl: string
- species: string
- }
- bondId?: string
- createTime: string
-}
+import { AnimalRecord } from '../../types/records'
const hiddenIndices = (process.env.NEXT_PUBLIC_HIDDEN_INDICES?.split(',') || [])
.map(num => parseInt(num))
@@ -97,35 +72,35 @@ export default function AnimalsPage() {
}
return (
-
- {records.map((record, index) => (
-
-
-

-
+
+ {records.map((record, index) => (
+
+
+

+
-
- {record.species}
-
+
+ {record.attributes?.mainObject}
+
-
-
-
- {record.location.latitude}°, {record.location.longitude}°
-
-
+
+
+
+ {record.attributes?.location.latitude}°, {record.attributes?.location.longitude}°
+
+
-
- {record.description}
-
-
+
+ {record.attributes?.description}
+
+
))}
)
diff --git a/src/services/googleVisionCore.ts b/src/services/googleVisionCore.ts
index 599c7af..33dc578 100644
--- a/src/services/googleVisionCore.ts
+++ b/src/services/googleVisionCore.ts
@@ -6,7 +6,7 @@ export interface VisionAnalysisResult {
description: string
mainObject: string
isAnimal: boolean
- matchedLabel: string // Add this to store which label was matched
+ matchedLabel: string
rawResponse: any
}
@@ -53,25 +53,27 @@ export async function analyzeImageWithVision(imageBuffer: Buffer): Promise
ANIMAL_LABELS.includes(label.description.toLowerCase())
)?.description || ''
- console.log('Vision API labels:', labels.map(l => l.description))
- console.log('Matched animal label:', matchedLabel)
-
const isAnimal = !!matchedLabel
- // Get the first animal label as main object
- const mainObject = matchedLabel || 'Unknown'
+ // For mainObject, use the first/highest confidence label from Vision API
+ // This will be its best guess at the specific species/type
+ const mainObject = labels[0]?.description || 'Unknown'
+
+ console.log('Vision API labels:', labels.map(l => l.description))
+ console.log('Validation label match:', matchedLabel)
+ console.log('Selected main object:', mainObject)
const { description } = constructDescription(labels, objects)
return {
description,
- mainObject,
- isAnimal,
+ mainObject, // Best species guess from Vision API
+ isAnimal, // Validation result using ANIMAL_LABELS
matchedLabel,
rawResponse: data.responses[0]
}
diff --git a/src/services/laconicQueryService.ts b/src/services/laconicQueryService.ts
index 40020d4..13127bb 100644
--- a/src/services/laconicQueryService.ts
+++ b/src/services/laconicQueryService.ts
@@ -1,17 +1,6 @@
// src/services/laconicQueryService.ts
-interface AnimalRecord {
- id: string
- mainObject: string
- species: string
- location: {
- latitude: number
- longitude: number
- }
- description: string
- imageUrl: string
- createTime: string
-}
+import { AnimalRecord } from '../types/records'
const LACONIC_GQL_ENDPOINT = process.env.NEXT_PUBLIC_LACONIC_GQL_ENDPOINT || 'https://laconicd-sapo.laconic.com/api'
@@ -84,18 +73,21 @@ export async function fetchAnimalRecords(): Promise {
}
return {
- species: attributesMap.species || 'Unknown Species',
- location: {
- latitude: location.latitude || 0,
- longitude: location.longitude || 0
+ id: record.id,
+ attributes: {
+ mainObject: attributesMap.mainObject || 'Unknown',
+ location: {
+ latitude: location.latitude || 0,
+ longitude: location.longitude || 0
+ },
+ description: attributesMap.description || 'No description',
+ imageUrl: attributesMap.imageUrl || null,
},
- description: attributesMap.description || 'No description',
- imageUrl: attributesMap.imageUrl || null,
createTime: record.createTime || ''
}
})
// Filter out records without an imageUrl
- .filter((record: AnimalRecord) => record.imageUrl !== null && record.imageUrl.trim() !== '');
+ .filter((record: AnimalRecord) => record.attributes.imageUrl !== null && record.attributes.imageUrl.trim() !== '');
console.log('Processed animal records:', records);
diff --git a/src/services/laconicService.ts b/src/services/laconicService.ts
index c4cf290..1ff7afd 100644
--- a/src/services/laconicService.ts
+++ b/src/services/laconicService.ts
@@ -10,7 +10,7 @@ const execAsync = promisify(exec)
interface LaconicAnimalRecord {
record: {
type: 'AnimalRecord'
- species: string
+ mainObject: string // changed from species
location: {
latitude: number
longitude: number
@@ -21,7 +21,7 @@ interface LaconicAnimalRecord {
}
export async function publishAnimalRecord(
- species: string,
+ mainObject: string, // changed parameter name
latitude: number,
longitude: number,
description: string,
@@ -35,7 +35,7 @@ export async function publishAnimalRecord(
const record: LaconicAnimalRecord = {
record: {
type: 'AnimalRecord',
- species,
+ mainObject, // use mainObject instead of species
location: {
latitude,
longitude
diff --git a/src/types/records.ts b/src/types/records.ts
new file mode 100644
index 0000000..4d6db6f
--- /dev/null
+++ b/src/types/records.ts
@@ -0,0 +1,16 @@
+// src/types/records.ts
+
+export interface AnimalRecord {
+ id: string
+ attributes: {
+ mainObject: string
+ location: {
+ latitude: number
+ longitude: number
+ }
+ description: string
+ imageUrl: string
+ }
+ bondId?: string
+ createTime: string
+}