module
CrystalMistral::Methods::FIM
Direct including types
Defined in:
crystal-mistral/methods/fim.crInstance Method Summary
-
#code(model : String, prompt : String, suffix : String = "", temperature : Float32 = 1) : ChatResponse
Sends a code completion (FIM - Fill-in-the-Middle) request to the Mistral API.
Instance Method Detail
def code(model : String, prompt : String, suffix : String = "", temperature : Float32 = 1) : ChatResponse
#
Sends a code completion (FIM - Fill-in-the-Middle) request to the Mistral API.
Arguments:
- model : String — the model name for code completion (e.g., "codestral-2405")
- prompt : String — the prefix (before cursor) code snippet
- suffix : String = "" — the suffix (after cursor) code snippet
- temperature : Float32 = 1.0 — controls randomness; lower is more deterministic
Returns:
- ChatResponse — includes the generated code completion
Raises:
- ArgumentError if model or prompt is empty
- RuntimeError via
handle_error
if the response indicates an error
Example:
client = CrystalMistral::Client.new
response = client.code(
model: "codestral-2405",
prompt: "def hello(name : String)",
suffix: "",
temperature: 0.7
)
puts "Generated code:\n#{puts resp.choices[0].message.content}"