⚡ Crystal Mistral Client
Installation
-
Add the dependency to your
shard.yml
:dependencies: crystal-mistral: github: Skrebnevf/crystal-mistral
-
Run
shards install
🖥️ Usage
require "crystal-mistral"
# API key can be passed directly or loaded from ENV["MISTRAL_API_KEY"]
client = CrystalMistral::Client.new
💬 Chat Completion
messages = [
Messages.new(role: Role::User, content: "Hello!")
]
response = client.chat(
model: "mistral-large-latest",
messages: messages,
temperature: 0.7_f32
)
puts response.choices[0].message.content
💻 Code Completion
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}"
🧠 Embeddings
texts = ["Let's compare London and Paris", "Compare?!"]
response = client.embeddings(
model: "mistral-embed",
input: texts
)
response.data.each_with_index do |embedding, idx|
puts "Embedding ##{idx}: #{embedding.embedding[0..4]}"
end
✔️ TODO
- [x] Add Chat Completion
- [x] Add Embeddings
- [ ] Add Tests
- [x] Add FIM
- [ ] Add Agents
- [ ] Add Classifiers
- [ ] Add Files
- [ ] Add Fine Tuning
🤝 Contributing
- Fork it (https://github.com/Skrebnevf/crystal-mistral/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
🏠 Contributors
- f.skrebnev - creator and maintainer
- @hope_you_die - TG