OCaml Claude SDK using Eio and Jsont
at main 40 lines 1.7 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Claude AI model identifiers. 7 8 This module provides type-safe model identifiers based on the Python SDK's 9 model strings. Use polymorphic variants for known models with a custom 10 escape hatch for future or unknown models. *) 11 12type t = 13 [ `Sonnet_4_5 (** claude-sonnet-4-5 - Most recent Sonnet model *) 14 | `Sonnet_4 (** claude-sonnet-4 - Sonnet 4 model *) 15 | `Sonnet_3_5 (** claude-sonnet-3-5 - Sonnet 3.5 model *) 16 | `Opus_4_5 (** claude-opus-4-5 - Most recent Opus model *) 17 | `Opus_4_1 (** claude-opus-4-1 - Opus 4.1 model *) 18 | `Opus_4 (** claude-opus-4 - Opus 4 model for complex tasks *) 19 | `Haiku_4 (** claude-haiku-4 - Fast, cost-effective Haiku model *) 20 | `Custom of string (** Custom model string for future/unknown models *) ] 21(** The type of Claude models. *) 22 23val to_string : t -> string 24(** [to_string t] converts a model to its CLI string representation. 25 26 Examples: 27 - [`Sonnet_4_5] becomes "claude-sonnet-4-5" 28 - [`Opus_4_5] becomes "claude-opus-4-5" 29 - [`Opus_4] becomes "claude-opus-4" 30 - [`Custom "my-model"] becomes "my-model" *) 31 32val of_string : string -> t 33(** [of_string s] parses a model string into a typed model. 34 35 Known model strings are converted to their typed variants. Unknown strings 36 become [`Custom s]. 37 38 Examples: 39 - "claude-sonnet-4-5" becomes [`Sonnet_4_5] 40 - "future-model" becomes [`Custom "future-model"] *)