package chatoyant

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

chatoyant-v0.13.0.tbz
sha256=1f84c5229b2d58ec6264dd651a58f2686130afa6e91989f110aa7aaf10bba0f5
sha512=49142e122dbb44b03f7f27b52839492800332207d0efeacc7451173827c899a9b965b671a3d9028cc05250aaebbc6789d3815a6cf356f4319bc0c1b0454c68dd

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