summaryrefslogtreecommitdiff
path: root/src/nlp/ocr.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-23 02:37:15 +0700
committerpolwex <polwex@sortug.com>2025-07-23 02:37:15 +0700
commit42dd99bfac9777a4ecc6700b87edf26a5c984de6 (patch)
tree031e45d187f45def4b58ad7590d39dec3924600d /src/nlp/ocr.ts
parent4c6913644b362b28f15b125c2fbe48165f1e048c (diff)
checkpoint
Diffstat (limited to 'src/nlp/ocr.ts')
-rw-r--r--src/nlp/ocr.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nlp/ocr.ts b/src/nlp/ocr.ts
new file mode 100644
index 0000000..1c40355
--- /dev/null
+++ b/src/nlp/ocr.ts
@@ -0,0 +1,18 @@
+import type { AsyncRes } from "sortug";
+
+export async function ocr(formData: FormData): AsyncRes<string[]> {
+ const endpoint = "http://localhost:8102/ocr";
+
+ const opts = {
+ method: "POST",
+ body: formData,
+ headers: { "X-API-KEY": Bun.env.SORTUG_NLP_API_KEY! },
+ };
+ try {
+ const res = await fetch(endpoint, opts);
+ const j = await res.json();
+ return { ok: j };
+ } catch (e) {
+ return { error: `${e}` };
+ }
+}