Ollama-sdk
An idiomatic Rust library for interacting with the Ollama API, focusing on streaming, tool calling, and ease of use.
Note: This is not an official Ollama SDK.
Features
- Idiomatic Rust API: Designed with Rust's best practices in mind.
- Streaming Responses: Efficiently handle streaming responses from the Ollama API.
- Tool Calling Support: Seamless integration with Ollama's tool calling capabilities.
- Configurable Transport: Uses
reqwestby default, with an extensibleTransporttrait for custom implementations. - Robust Error Handling: Comprehensive error types for predictable error management.
- Observability: Optional
tracingfor detailed logging andmetricsfor performance monitoring.
Installation
Note that:
ollama-sdkis not yet published on crates.io. You need to include it via Git.
Add ollama-sdk to your Cargo.toml file:
[]
= { = "https://github.com/Sathiyaraman-M/Ollama-sdk.git", = "main" }
To enable optional features like tracing or metrics:
[]
= { = "https://github.com/Sathiyaraman-M/Ollama-sdk.git", = "main", = ["tracing", "metrics"] }
Usage
Basic Chat (non-streaming)
use OllamaClient;
use Message;
use Role;
async
Streaming Chat
use OllamaClient;
use Message;
use Role;
use StreamExt;
async
Contributing
We welcome contributions! Please see our CONTRIBUTING.md for more details.
License
This project is licensed under the MIT License. See the LICENSE file for details.