$ 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 bindings for OpenAI API
License
Nymphium/openai-ocaml
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
OCaml bindings for OpenAI API
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published