-
Notifications
You must be signed in to change notification settings - Fork 5
/
fetch_embeddings.lean
25 lines (22 loc) · 1.06 KB
/
fetch_embeddings.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Cache.IO
import LeanAide.Aides
open Lean Cache.IO
unsafe def fetchEmbedding (descField : String) (force: Bool) : IO UInt32 := do
let picklePath ← picklePath descField
if (← picklePath.pathExists) && !force then
IO.eprintln s!"Embeddings already present at {picklePath}, use --force to redownload."
IO.eprintln "Fetching embeddings ..."
IO.eprintln s!"https://storage.googleapis.com/leanaide_data/{picklePath.fileName.get!}"
let out ← IO.Process.output {cmd:= "curl", args:=#["--output", picklePath.toString, s!"https://storage.googleapis.com/leanaide_data/{picklePath.fileName.get!}"]}
IO.eprintln "Fetched embeddings"
if out.exitCode != 0 then
IO.eprintln s!"Failed to fetch embeddings: {out.stderr}"
else
IO.eprintln s!"Fetched embeddings: {out.stdout}"
return out.exitCode
unsafe def main (args: List String) : IO UInt32 := do
let force := args.any (· == "--force")
for descField in ["docString", "description", "concise-description"] do
let res ← fetchEmbedding descField force
if res != 0 then return res
return 0