Skip to content

Commit

Permalink
chore: updated open ai lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed May 1, 2024
1 parent da89f05 commit c898381
Show file tree
Hide file tree
Showing 6 changed files with 518 additions and 426 deletions.
23 changes: 21 additions & 2 deletions src/Informedica.OpenAI.Lib/Extraction.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,27 @@ module Extraction =
let _ = JsonConvert.DeserializeObject<{| frequencies : int list; timeUnit : string |}>(s)
s |> Ok
with
| e -> $"The answer: {s} was not correct because:\n{e.ToString()}" |> Error
| e -> $"The answer: |{s}| was not correct because:\n{e.ToString()}" |> Error

Prompts.User.frequencyText timeUnit zero
|> Message.userWithValidator validator
|> extract jsonFreq model zero
|> extract jsonFreq model zero


let extractDoseQuantities json model substanceUnit adjustUnit timeUnit =
let zero = {| quantities = [||]|}
let validator =
fun s ->
try
let _ = JsonConvert.DeserializeObject<{| quantities : {| minQty : float; maxQty : float; unit : string |}[]|}>(s)
s |> Ok
with
| e ->
let msg = $"The answer: {s} was not correct because:\n{e.ToString()}"
printfn $"{msg}"
msg
|> Error

Prompts.User.minMaxDoseText substanceUnit adjustUnit timeUnit
|> Message.userWithValidator validator
|> extract json model zero
Loading

0 comments on commit c898381

Please sign in to comment.