@@ -74,15 +74,15 @@ def ExternalGenerator.generate (model : ExternalGenerator) (input : String) (tar
7474 return res.outputs.map fun g => (g.output, g.score)
7575
7676
77- def generateRunpod (input : String) (modelName : String) (targetPrefix : String) : IO $ Array (String × Float) := do
77+ def generateRunpod (input : String) (modelName : String) (_targetPrefix : String) : IO $ Array (String × Float) := do
7878 let url := "https://router.huggingface.co/v1/chat/completions"
79-
79+
8080 -- Format the prompt (same as Python pre_process_input)
8181 let prompt := if modelName == "deepseek" then
8282 s! "Here is a theorem you need to prove in Lean:```lean\n { input} ```\n Now you should suggest exactly one line tactic in lean code. Only output the tactic, no explanation, no comments, no theorem, nothing else:"
8383 else
8484 input
85-
85+
8686 -- Build JSON payload
8787 let message := Json.mkObj [("role" , Json.str "user" ), ("content" , Json.str prompt)]
8888 let messages := Json.arr #[message]
@@ -95,38 +95,38 @@ def generateRunpod (input : String) (modelName : String) (targetPrefix : String)
9595 ("n" , Json.num 4 )
9696 ]
9797 let reqStr := reqJson.pretty 99999999999999999
98-
98+
9999 -- Read HF_TOKEN from .env file in current directory
100100 let envFile := ".env"
101101 let envContent ← IO.FS.readFile envFile
102102 let lines := envContent.splitOn "\n "
103103 let mut token := ""
104104 for line in lines do
105105 if line.startsWith "HF_TOKEN=" then
106- token := line.drop 9 -- Remove "HF_TOKEN=" prefix
106+ token := ( line.drop 9 ).toString -- Remove "HF_TOKEN=" prefix
107107 if token == "" then
108108 throw $ IO.userError "HF_TOKEN not found in .env file. Please create a .env file with: HF_TOKEN=your_token_here"
109-
109+
110110 -- Make API call
111111 let out ← IO.Process.output {
112112 cmd := "curl"
113113 args := #["-X" , "POST" , url, "-H" , "accept: application/json" , "-H" , "Content-Type: application/json" , "-H" , s! "Authorization: Bearer { token} " , "-d" , reqStr]
114114 }
115115 if out.exitCode != 0 then
116116 throw $ IO.userError s! "Request failed. Please check if the API is accessible at `{ url} `."
117-
117+
118118 -- Parse response
119119 let some json := Json.parse out.stdout |>.toOption
120120 | throw $ IO.userError "Failed to parse response"
121-
121+
122122 -- Debug: print raw response
123123 IO.println s! "Raw API response: { out.stdout} "
124-
124+
125125 let some choices := json.getObjVal? "choices" |>.toOption
126126 | throw $ IO.userError "No choices in response"
127127 let some choicesArray := choices.getArr? |>.toOption
128128 | throw $ IO.userError "Choices is not an array"
129-
129+
130130 -- Extract and clean responses (same as Python post_process_output)
131131 let mut results : Array (String × Float) := #[]
132132 for choice in choicesArray do
@@ -140,19 +140,19 @@ def generateRunpod (input : String) (modelName : String) (targetPrefix : String)
140140 let cleaned := if modelName == "deepseek" then
141141 -- Extract content between backticks
142142 if contentStr.startsWith "`" && contentStr.endsWith "`" then
143- contentStr.drop 1 |>.dropRight 1 -- Remove first and last backtick
143+ contentStr.drop 1 |>.dropEnd 1 -- Remove first and last backtick
144144 else
145145 contentStr
146146 else
147147 contentStr
148- results := results.push (cleaned, 1 .0 )
149-
148+ results := results.push (cleaned.toString , 1 .0 )
149+
150150 -- Deduplicate (same as Python choices_dedup)
151151 let mut uniqueData : List (String × Float) := []
152152 for result in results do
153153 if !uniqueData.any (·.1 == result.1 ) then
154154 uniqueData := uniqueData.append [result]
155-
155+
156156 return uniqueData.toArray
157157
158158
0 commit comments