package chatoyant

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

chatoyant-v0.12.1.tbz
sha256=72752addb69fe17825f43f5a861f8d0a7817f6a5a711916e722023e10679daff
sha512=d1a62989e34f8b9173d4c53f8e17c611900855df8a139888e73ee509b445ef1e65105c17bb399bf25712a893a251827513f18ed36d0e2b3fcc908fb00584c6f3

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