diff --git a/.env.example b/.env.example deleted file mode 100644 index ad6f95e..0000000 --- a/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -# This key is only used for development purposes. -# You'll only need one if you want to contribute to this library. -export MISTRAL_API_KEY= diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 668904f..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "" -labels: "bug" -assignees: "" ---- - -**Describe the bug** - -... - -**Reproduction** - -Steps to reproduce the behavior: - -1. ... -2. ... - -**Expected behavior** - -... - -**Screenshots** - -If applicable, add screenshots to help explain your problem. - -**Version** - -If applicable, what version did you use? - -**Environment** - -If applicable, add relevant information about your config and environment here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 0e5a2a4..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Feature request -about: Suggest a new idea for the project. -title: "" -labels: "enhancement" -assignees: "" ---- - -**Is your feature request related to some problems?** - -- _Ex. I'm always frustrated when..._ - -**What are the solutions you'd like?** - -- _Ex. A new option to..._ - -**Anything else?** - -- ... diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 6e32d77..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,8 +0,0 @@ -## Description - -A clear and concise description of what your pull request is about. - -## Checklist - -- [ ] I updated the documentation accordingly. Or I don't need to. -- [ ] I updated the tests accordingly. Or I don't need to. diff --git a/.github/renovate.json b/.github/renovate.json deleted file mode 100644 index 6a36a09..0000000 --- a/.github/renovate.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["github>ivangabriele/renovate-config"] -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ba0f13f..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Test - -on: - pull_request: - push: - -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.76.0 - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov - - name: Run tests (with coverage) - run: cargo llvm-cov --lcov --output-path ./lcov.info - env: - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - - name: Upload tests coverage - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: true - files: ./lcov.info - token: ${{ secrets.CODECOV_TOKEN }} - - test_documentation: - name: Test Documentation - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.76.0 - - name: Run documentation tests - run: make test-doc - env: - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - - test_examples: - name: Test Examples - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.76.0 - - name: Run examples - run: make test-examples - env: - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index dc62558..d6fdb17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ +# Changelog + +## [1.0.0](https://src.sunbeam.pt/studio/mistralai-client-rs) (2026-03-20) + +Forked from [ivangabriele/mistralai-client-rs](https://github.com/ivangabriele/mistralai-client-rs) v0.14.0 and updated to the latest Mistral AI API. + +### ⚠ BREAKING CHANGES + +* `Model` is now a string-based struct with constructor methods instead of a closed enum +* `EmbedModel` is removed — use `Model::mistral_embed()` instead +* `Tool::new()` parameters now accept `serde_json::Value` (JSON Schema) instead of limited enum types +* `ChatParams.temperature` is now `Option` instead of `f32` +* Stream delta `content` is now `Option` + +### Features + +* Add all current Mistral models (Large 3, Small 4, Medium 3.1, Magistral, Codestral, Devstral, Pixtral, Voxtral, Ministral) +* Add FIM (fill-in-the-middle) completions endpoint +* Add Files API (upload, list, get, delete, download URL) +* Add Fine-tuning jobs API (create, list, get, cancel, start) +* Add Batch jobs API (create, list, get, cancel) +* Add OCR endpoint (document text extraction) +* Add Audio transcription endpoint +* Add Moderations and Classifications endpoints +* Add Agent completions endpoint +* Add new chat fields: frequency_penalty, presence_penalty, stop, n, min_tokens, parallel_tool_calls, reasoning_effort, json_schema response format +* Add embedding fields: output_dimension, output_dtype +* Add tool call IDs and Required tool choice variant +* Add model get and delete endpoints + +--- + +## Upstream Changelog (pre-fork) + ## [0.14.0](https://github.com/ivangabriele/mistralai-client-rs/compare/v0.13.0...v) (2024-08-27) ### Features diff --git a/Cargo.toml b/Cargo.toml index cc836ef..d134f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ version = "1.0.0" edition = "2021" rust-version = "1.76.0" -authors = ["Ivan Gabriele "] +authors = ["Sunbeam Studios "] categories = ["api-bindings"] -homepage = "https://src.sunbeam.pt/studio/mistralai-client-rs" +homepage = "https://sunbeam.pt" keywords = ["mistral", "mistralai", "client", "api", "llm"] readme = "README.md" repository = "https://src.sunbeam.pt/studio/mistralai-client-rs" diff --git a/Makefile b/Makefile deleted file mode 100644 index c074233..0000000 --- a/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -SHELL := /bin/bash - -.PHONY: doc readme test - -define source_env_if_not_ci - @if [ -z "$${CI}" ]; then \ - if [ -f ./.env ]; then \ - source ./.env; \ - else \ - echo "No .env file found"; \ - exit 1; \ - fi \ - fi -endef - -define RELEASE_TEMPLATE - npx conventional-changelog-cli -p conventionalcommits -i ./CHANGELOG.md -s - git add . - git commit -m "docs(changelog): update" - git push origin HEAD - cargo release $(1) --execute - git push origin HEAD --tags -endef - -doc: - cargo doc - open ./target/doc/mistralai_client/index.html - -readme: - @echo "Generating README.md from template..." - @> README.md # Clear README.md content before starting - @while IFS= read -r line || [[ -n "$$line" ]]; do \ - if [[ $$line == *""* && $$line == *""* ]]; then \ - example_path=$$(echo $$line | sed -n 's/.*\(.*\)<\/CODE>.*/\1/p'); \ - if [ -f $$example_path ]; then \ - echo '```rs' >> README.md; \ - cat $$example_path >> README.md; \ - echo '```' >> README.md; \ - else \ - echo "Error: Example $$example_path not found." >&2; \ - fi; \ - else \ - echo "$$line" >> README.md; \ - fi; \ - done < README.template.md - @echo "README.md has been generated." - -release-patch: - $(call RELEASE_TEMPLATE,patch) -release-minor: - $(call RELEASE_TEMPLATE,minor) -release-major: - $(call RELEASE_TEMPLATE,major) - -test: - @$(source_env_if_not_ci) && \ - cargo test --no-fail-fast -test-cover: - @$(source_env_if_not_ci) && \ - cargo llvm-cov -test-doc: - @$(source_env_if_not_ci) && \ - cargo test --doc --no-fail-fast -test-examples: - @$(source_env_if_not_ci) && \ - for example in $$(ls examples/*.rs | sed 's/examples\/\(.*\)\.rs/\1/'); do \ - echo "Running $$example"; \ - cargo run --example $$example; \ - done -test-watch: - @source ./.env && \ - cargo watch -x "test -- --nocapture" diff --git a/README.template.md b/README.template.md deleted file mode 100644 index 285fead..0000000 --- a/README.template.md +++ /dev/null @@ -1,127 +0,0 @@ -# Mistral AI Rust Client - -[![Crates.io Package](https://img.shields.io/crates/v/mistralai-client?style=for-the-badge)](https://crates.io/crates/mistralai-client) -[![Docs.rs Documentation](https://img.shields.io/docsrs/mistralai-client/latest?style=for-the-badge)](https://docs.rs/mistralai-client/latest/mistralai-client) -[![Test Workflow Status](https://img.shields.io/github/actions/workflow/status/ivangabriele/mistralai-client-rs/test.yml?label=CI&style=for-the-badge)](https://github.com/ivangabriele/mistralai-client-rs/actions?query=branch%3Amain+workflow%3ATest++) -[![Code Coverage](https://img.shields.io/codecov/c/github/ivangabriele/mistralai-client-rs/main?label=Cov&style=for-the-badge)](https://app.codecov.io/github/ivangabriele/mistralai-client-rs) - -Rust client for the Mistral AI API. - -> [!IMPORTANT] -> While we are in v0, minor versions may introduce breaking changes. -> Please, refer to the [CHANGELOG.md](./CHANGELOG.md) for more information. - ---- - -- [Supported APIs](#supported-apis) -- [Installation](#installation) - - [Mistral API Key](#mistral-api-key) - - [As an environment variable](#as-an-environment-variable) - - [As a client argument](#as-a-client-argument) -- [Usage](#usage) - - [Chat](#chat) - - [Chat (async)](#chat-async) - - [Chat with streaming (async)](#chat-with-streaming-async) - - [Chat with Function Calling](#chat-with-function-calling) - - [Chat with Function Calling (async)](#chat-with-function-calling-async) - - [Embeddings](#embeddings) - - [Embeddings (async)](#embeddings-async) - - [List models](#list-models) - - [List models (async)](#list-models-async) -- [Contributing](#contributing) - ---- - -## Supported APIs - -- [x] Chat without streaming -- [x] Chat without streaming (async) -- [x] Chat with streaming -- [x] Embedding -- [x] Embedding (async) -- [x] List models -- [x] List models (async) -- [x] Function Calling -- [x] Function Calling (async) - -## Installation - -You can install the library in your project using: - -```sh -cargo add mistralai-client -``` - -### Mistral API Key - -You can get your Mistral API Key there: . - -#### As an environment variable - -Just set the `MISTRAL_API_KEY` environment variable. - -```rs -use mistralai_client::v1::client::Client; - -fn main() { - let client = Client::new(None, None, None, None); -} -``` - -```sh -MISTRAL_API_KEY=your_api_key cargo run -``` - -#### As a client argument - -```rs -use mistralai_client::v1::client::Client; - -fn main() { - let api_key = "your_api_key"; - - let client = Client::new(Some(api_key), None, None, None).unwrap(); -} -``` - -## Usage - -### Chat - -examples/chat.rs - -### Chat (async) - -examples/chat_async.rs - -### Chat with streaming (async) - -examples/chat_with_streaming.rs - -### Chat with Function Calling - -examples/chat_with_function_calling.rs - -### Chat with Function Calling (async) - -examples/chat_with_function_calling_async.rs - -### Embeddings - -examples/embeddings.rs - -### Embeddings (async) - -examples/embeddings_async.rs - -### List models - -examples/list_models.rs - -### List models (async) - -examples/list_models_async.rs - -## Contributing - -Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to contribute to this library. diff --git a/justfile b/justfile new file mode 100644 index 0000000..c914d06 --- /dev/null +++ b/justfile @@ -0,0 +1,27 @@ +check: + cargo check --all-targets + +doc: + cargo doc --open + +fmt: + cargo fmt + +lint: + cargo clippy --all-targets + +publish: + cargo publish --registry sunbeam + +test: + cargo test --no-fail-fast + +test-cover: + cargo llvm-cov + +test-examples: + #!/usr/bin/env bash + for example in $(ls examples/*.rs | sed 's/examples\/\(.*\)\.rs/\1/'); do + echo "Running $example" + cargo run --example "$example" + done