Skip to content

Commit 10a61ce

Browse files
committed
whattheduck: Update histoire
web: Show image search result scores
1 parent 003f4b0 commit 10a61ce

File tree

4 files changed

+412
-532
lines changed

4 files changed

+412
-532
lines changed

apps/web/src/pages/image-search-test.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ meta:
2121
<img
2222
v-for="example in examples"
2323
:key="example.url"
24-
:class="{ 'h-100': true, disabled: example.isCover !== isCover }"
24+
:class="{ disabled: example.isCover !== isCover }"
2525
:src="example.url"
2626
@click="handleExampleClick(example)"
2727
/>
@@ -103,7 +103,10 @@ const models = ref<
103103
return "error" in searchResults
104104
? searchResults.errorDetails || "Error"
105105
: JSON.stringify(
106-
searchResults.covers.map(({ issuecode }) => issuecode),
106+
searchResults.covers.map(({ issuecode, score }) => ({
107+
issuecode,
108+
score,
109+
})),
107110
);
108111
} catch (error) {
109112
return typeof error === "object" && "errorDetails" in error!
@@ -213,6 +216,7 @@ onMounted(async () => {
213216
<style scoped lang="scss">
214217
img {
215218
cursor: pointer;
219+
height: 100px;
216220
217221
&.disabled {
218222
opacity: 0.5;

apps/whattheduck/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@eslint/compat": "^1.3.1",
7474
"@eslint/eslintrc": "^3.3.1",
7575
"@eslint/js": "^9.31.0",
76-
"@histoire/plugin-vue": "^0.17.17",
76+
"@histoire/plugin-vue": "1.0.0-alpha.2",
7777
"@intlify/eslint-plugin-vue-i18n": "^4.0.1",
7878
"@intlify/unplugin-vue-i18n": "^6.0.8",
7979
"@ionic/cli": "^7.2.1",
@@ -95,7 +95,7 @@
9595
"eslint-plugin-unused-imports": "^4.1.4",
9696
"eslint-plugin-vue": "^10.3.0",
9797
"globals": "^15.15.0",
98-
"histoire": "^0.17.17",
98+
"histoire": "1.0.0-alpha.2",
9999
"jsdom": "^24.1.3",
100100
"prettier": "^3.6.2",
101101
"typescript": "^5.8.3",

packages/api/services/story-search/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ export const findSimilarImages = async (
164164
vector_similarity AS (
165165
SELECT
166166
ev.entrycode,
167-
VEC_DISTANCE_COSINE(ev.v, (SELECT v from inputVector)) as score
167+
VEC_DISTANCE_COSINE(ev.v, (SELECT v from inputVector)) as similarity
168168
FROM inducks_entryurl_vector ev WHERE is_cover=${isCover}
169169
)
170170
SELECT
171171
vector_similarity.entrycode,
172-
vector_similarity.score,
172+
1 - vector_similarity.similarity as score,
173173
e.issuecode,
174174
sv.storyversioncode
175175
FROM vector_similarity
176176
INNER JOIN inducks_entry e ON e.entrycode = vector_similarity.entrycode
177177
INNER JOIN inducks_storyversion sv ON sv.storyversioncode = e.storyversioncode
178-
WHERE score < 0.15
179-
ORDER BY score
178+
WHERE similarity < 0.15
179+
ORDER BY similarity
180180
LIMIT 5
181181
`;
182182
console.log("Query done, results:", results);

0 commit comments

Comments
 (0)