Skip to content

Commit

Permalink
Refactor imports and add error handling
Browse files Browse the repository at this point in the history
- Add missing import for `syscall` in `embeddings.test.ts`
- Update error handling message formatting in `embeddings.ts`
- Export `syscall` from `mocks/syscalls.ts` for consistency
  • Loading branch information
justyns committed Sep 8, 2024
1 parent 3a61c49 commit 83ecca2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/embeddings.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import "./mocks/syscalls.ts";
import { syscall } from "./mocks/syscalls.ts";
import { aiSettings, initializeOpenAI } from "./init.ts";
import {
canIndexPage,
indexEmbeddings,
shouldIndexEmbeddings,
shouldIndexSummaries,
} from "./embeddings.ts";
Expand Down
4 changes: 2 additions & 2 deletions src/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ export async function updateSearchPage() {
queryEmbedding = await generateEmbeddingsOnServer(phrase);
} catch (error) {
console.error("Error generating query vector embeddings", error);
loadingText +=
"\n\n> **error** ⚠️ Failed to generate query vector embeddings.\n";
// deno-fmt-ignore
loadingText += "\n\n> **error** ⚠️ Failed to generate query vector embeddings.\n";
loadingText += `> ${error}\n\n`;
await editor.setText(loadingText);
return;
Expand Down
3 changes: 3 additions & 0 deletions src/mocks/syscalls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parse as parseYAML } from "https://deno.land/std@0.216.0/yaml/mod.ts";
import { parseMarkdown } from "$common/markdown_parser/parser.ts";
import { syscall } from "@silverbulletmd/silverbullet/syscalls";

let editorText = "Mock data";
(globalThis as any).editorText;
Expand Down Expand Up @@ -71,3 +72,5 @@ function invokeFunctionMock(args: readonly any[]) {
throw Error(`Missing invokeFunction mock for ${args[0]}`);
}
}

export { syscall };

0 comments on commit 83ecca2

Please sign in to comment.