@@ -17,43 +17,13 @@ export const searchByText = async (query, limit = 50, page = 1) => {
1717 }
1818
1919 const { results } = await response . json ( ) ;
20-
21- return results . map ( item => ( {
22- id : item . id ,
23- file_path : item . file_path ,
24- file_name : item . file_name ,
25- similarity : item . score ,
26- metadata : {
27- title : item . file_name ,
28- path : item . file_path ,
29- }
30- } ) ) ;
20+ return results ;
3121 } catch ( error ) {
3222 console . error ( 'Error searching photos:' , error ) ;
3323 throw error ;
3424 }
3525} ;
3626
37- /**
38- * Get statistics about embeddings (total count)
39- * @returns {Promise<Object> } - Statistics object with count property
40- */
41- export const getEmbeddingStats = async ( ) => {
42- try {
43- const response = await fetch ( `${ API_URL } /api/embeddings/count` ) ;
44-
45- if ( ! response . ok ) {
46- throw new Error ( `API error: ${ response . status } ` ) ;
47- }
48-
49- const data = await response . json ( ) ;
50- return data ;
51- } catch ( error ) {
52- console . error ( 'Error fetching embedding stats:' , error ) ;
53- return { count : 0 } ;
54- }
55- } ;
56-
5727/**
5828 * Search for similar photographs by image
5929 * @param {File } image - The image file to search with
@@ -77,10 +47,30 @@ export const searchByImage = async (image, limit = 50, page = 1) => {
7747 throw new Error ( `API error: ${ response . status } ` ) ;
7848 }
7949
80- const data = await response . json ( ) ;
81- return data ;
50+ const { results } = await response . json ( ) ;
51+ return results ;
8252 } catch ( error ) {
8353 console . error ( 'Error in image search:' , error ) ;
8454 throw error ;
8555 }
8656} ;
57+
58+ /**
59+ * Get statistics about embeddings (total count)
60+ * @returns {Promise<Object> } - Statistics object with count property
61+ */
62+ export const getEmbeddingStats = async ( ) => {
63+ try {
64+ const response = await fetch ( `${ API_URL } /api/embeddings/count` ) ;
65+
66+ if ( ! response . ok ) {
67+ throw new Error ( `API error: ${ response . status } ` ) ;
68+ }
69+
70+ const data = await response . json ( ) ;
71+ return data ;
72+ } catch ( error ) {
73+ console . error ( 'Error fetching embedding stats:' , error ) ;
74+ return { count : 0 } ;
75+ }
76+ } ;
0 commit comments