Skip to content

Commit

Permalink
2.14.1: feat: can skip using note title for search when using ZK or w…
Browse files Browse the repository at this point in the history
…hen title doesnt reflect well note semantic
  • Loading branch information
louis030195 committed Jan 19, 2023
1 parent e441088 commit e12e579
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "ava",
"name": "🧙 AVA",
"version": "2.14.0",
"version": "2.14.1",
"minAppVersion": "0.12.0",
"description": "AI assistant for Obsidian",
"author": "louis030195",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ava",
"version": "2.14.0",
"version": "2.14.1",
"description": "AI assistant for Obsidian",
"main": "main.js",
"scripts": {
Expand Down
38 changes: 26 additions & 12 deletions src/LinkComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ const ControlForm = () => {
const { register, handleSubmit } = useForm();
const state = React.useSyncExternalStore(store.subscribe, store.getState);

const onSubmit = async (data: { limit: number }) => {
const onSubmit = async (data: { limit: number, useNoteTitle: boolean }) => {
posthog.capture('use-feature', {
feature: 'search',
limit: data.limit,
});
state.setEmbedsLoading(true);

const body: ISearchBody = {
query: state.currentFileContent,
note: {
note_path: state.currentFilePath,
note_tags: state.currentFileTags,
},
query: data.useNoteTitle ? `File:${state.currentFilePath}\n` : '' +
`Content:\n${state.currentFileContent}`,
vault_id: state.settings.vaultId,
top_k: Number(data.limit),
};
Expand All @@ -123,19 +120,36 @@ const ControlForm = () => {
return (
<div className="border-2 block rounded-md border-solid border-gray-300 p-4">
<form onSubmit={handleSubmit(onSubmit)}>
<div>
<label htmlFor="" className="block text-sm font-medium text-gray-700">
Max Results
</label>
<div className="mt-1">
{/* horizontal list of two items, one input number and one checkbox keep item top aligned spaced evenly */}
<div className="flex flex-col gap-3">
{/* vertical list */}
<div className="flex flex-col gap-2">
<label htmlFor="" className="block text-sm font-medium">
Max Results
</label>
<input
type="number"
className="block rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
className="block rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm w-max"
defaultValue={5}
placeholder="5"
{...register('limit', { required: true })}
/>
</div>
{/* vertical list checkbox "use note title" */}
<div className="flex gap-2 items-center">
<input
type="checkbox"
defaultChecked={true}
className="block rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
{...register('useNoteTitle', { required: false })}
/>
<label
htmlFor=""
className="block text-sm font-medium"
>
Use note title for search
</label>
</div>
</div>
<PrimaryButton className="mt-3 w-full">Search</PrimaryButton>
</form>
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ interface NoteRefresh {
noteTags?: string[];
noteContent?: string;
pathToDelete?: string;
noteEmbeddingFormat?: string;
}
/**
* Make a query to /refresh to refresh the semantic search index
Expand Down Expand Up @@ -247,6 +248,7 @@ export const refreshSemanticSearch = async (
note_tags: note.noteTags,
note_content: note.noteContent,
path_to_delete: note.pathToDelete,
note_embedding_format: note.noteEmbeddingFormat,
})),
}),
});
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@
"2.13.7": "0.12.0",
"2.13.8": "0.12.0",
"2.13.9": "0.12.0",
"2.14.0": "0.12.0"
"2.14.0": "0.12.0",
"2.14.1": "0.12.0"
}

0 comments on commit e12e579

Please sign in to comment.