package chatoyant

  1. Overview
  2. Docs
OCaml-first LLM SDK with Melange-generated JavaScript

Install

dune-project
 Dependency

Authors

Maintainers

Sources

chatoyant-v0.12.2.tbz
sha256=a885dcf4b3c6ede268e2027bedf6955a5c889f7ed01c40b719f8369655957d47
sha512=0bb8dfa12157ba2e482927717c2242c1ea914dce1427801e405987811550afbd6d6b11f07d1e1379259360d17f4ca43ff81963bf407cddb7bedd0dfbb93a55ee

doc/src/chatoyant.core/shortcuts.ml.html

Source file shortcuts.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Make
    (Provider : Chatoyant_provider.Provider.CHAT)
    (Clock : Chatoyant_runtime.Effect.CLOCK) =
struct
  module Chat = Session.Make (Provider) (Clock)

  let build_chat ?system ?model prompt =
    let chat =
      match model with
      | None -> Chat.create ()
      | Some model -> Chat.create ~model ()
    in
    let chat =
      match system with
      | None -> chat
      | Some content -> Chat.system content chat
    in
    Chat.user prompt chat

  let gen_result ?system ?model ?options prompt =
    let chat = build_chat ?system ?model prompt in
    Chat.generate_with_result ?options chat

  let gen_text ?system ?model ?options prompt =
    match gen_result ?system ?model ?options prompt with
    | Error _ as err -> err
    | Ok result -> Ok result.Result.content

  let gen_stream_accumulate ?system ?model ?(options = Options.default) frames
      prompt =
    let chat = build_chat ?system ?model prompt in
    Chat.stream_accumulate ~options frames chat
end