Skip to content

Commit 381c0b8

Browse files
committed
fix: Swallow exception when LLM isn't connected.
1 parent ec613bc commit 381c0b8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/DataFrame/DecisionTree.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import DataFrame.Operations.Core (columnNames, nRows)
2222
import DataFrame.Operations.Statistics (percentile)
2323
import DataFrame.Operations.Subset (exclude, filterWhere)
2424

25-
import Control.Exception (throw)
25+
import Control.Exception (SomeException, throw, try)
2626
import Control.Monad (guard)
2727
import Data.Containers.ListUtils (nubOrd)
2828
import Data.Function (on)
@@ -224,10 +224,14 @@ score expr =
224224
, prompt = T.pack (instructions ++ prettyPrint expr)
225225
}
226226
llamaConfig = Just (defaultOllamaConfig{hostUrl = "http://127.0.0.1:8080"})
227-
llmResponse = genResponse $ either throw id $ unsafePerformIO (generate genOp llamaConfig)
228-
s = fst $ either error id $ decimal @Int $ llmResponse
227+
result = unsafePerformIO $ try @SomeException (generate genOp llamaConfig)
229228
in
230-
trace (prettyPrint expr ++ ": " ++ show s) s
229+
case result of
230+
Right (Right response) ->
231+
let llmResponse = genResponse response
232+
s = fst $ either error id $ decimal @Int llmResponse
233+
in trace (prettyPrint expr ++ ": " ++ show s) s
234+
_ -> 7
231235

232236
numericExprs ::
233237
SynthConfig -> DataFrame -> [Expr Double] -> Int -> Int -> [Expr Double]

0 commit comments

Comments
 (0)