MCPcopy Create free account
hub / github.com/cactus-compute/cactus-react-native / indexQuery

Function indexQuery

example/src/IndexScreen.tsx:130–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 };
129
130 const indexQuery = async () => {
131 if (!query) {
132 console.warn('Please provide a query string.');
133 return;
134 }
135
136 try {
137 const queryEmbedding = await cactusLM.embed({ text: query });
138 const queryResult = await cactusIndex.query({
139 embeddings: [queryEmbedding.embedding],
140 options: { topK: 3, scoreThreshold: 0.1 },
141 });
142
143 console.log('Query results:', queryResult);
144 setQueryResults(queryResult);
145
146 if (!queryResult.ids[0]) {
147 console.log('No results found for the query.');
148 return;
149 }
150
151 setGetResults(await cactusIndex.get({ ids: queryResult.ids[0] }));
152 } catch (e) {
153 console.error('Error querying index:', e);
154 return;
155 }
156 };
157
158 if (cactusLM.isDownloading) {
159 return (

Callers

nothing calls this directly

Calls 4

embedMethod · 0.65
queryMethod · 0.65
getMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected