diff options
| author | polwex <polwex@sortug.com> | 2025-07-23 02:37:15 +0700 |
|---|---|---|
| committer | polwex <polwex@sortug.com> | 2025-07-23 02:37:15 +0700 |
| commit | 42dd99bfac9777a4ecc6700b87edf26a5c984de6 (patch) | |
| tree | 031e45d187f45def4b58ad7590d39dec3924600d /src/nlp/ocr.ts | |
| parent | 4c6913644b362b28f15b125c2fbe48165f1e048c (diff) | |
checkpoint
Diffstat (limited to 'src/nlp/ocr.ts')
| -rw-r--r-- | src/nlp/ocr.ts | 18 |
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}` }; + } +} |
