package openai

  1. Overview
  2. Docs
OCaml OpenAI binding

Install

Dune Dependency

Authors

Maintainers

Sources

openai-ocaml-0.0.1.tbz
sha256=aa7947b57001796a65e39cfed9c80338d08c5e2b7f2e32d0e6c19e1446395b18
sha512=46b236cb9bb25233fd4026d9593d161ced0f54b223c6d97ae3d981e2b36355ff60fd80cdefe7c6a247ef36251fe02999a65416b8fbfad50079232b9cb6cbc318

README.md.html

OpenAI-OCaml

$ cat src/test.ml
open Openai

let run () =
  let api_key = Sys.getenv "OPENAI_API_KEY" in
  let client = Client.create api_key in
  ignore
  @@ Lwt_main.run
  @@ Lwt.bind
       Chat_completion.(
         send
           client
           ~temperature:0.0
           ~max_tokens:22
           ~messages:
             [ { role = `System; content = "" }
             ; { role = `User; content = {|枕草子曰く、春は"あけぼの"、夜は"月"。では、秋は?|} }
             ]
           ())
       (Lwt_io.printlf "res: %s")
;;

let () = run ()
$ export OPENAI_API_KEY=...
$ dune test
res: 枕草子によると、秋は「夕暮れ」です。
OCaml

Innovation. Community. Security.