3 个版本
0.1.3 | 2024年7月13日 |
---|---|
0.1.2 | 2024年7月10日 |
0.1.1 | 2024年7月10日 |
0.1.0 |
|
#768 in 机器学习
每月167次下载
9KB
121 行
Kazama
Ollama 客户端在 Rust 中 🦀
🤖 用于与 Ollama API 交互的 Rust 客户端库,支持聊天补全、模型拉取、嵌入生成、模型列表和模型推送等操作。
✅ 功能:
- 聊天补全:
chat_completion(model, content, role)
- 模型拉取:
pull_model(name, stream_mode)
- 生成嵌入:
gen_embeddings(model, prompt)
- 列出模型:
list_models()
- 推送模型:
push_models(name, stream_mode)
✅ 用法:
use kazama::{chat_completion, pull_model, gen_embeddings, list_models, push_models};
#[tokio::main]
async fn main() {
// Example: Chat Completion
chat_completion("model_name", "Hello!", "user").await.expect("Failed to complete chat");
// Example: Model Pull
pull_model("model_name", false).await.expect("Failed to pull model");
// Example: Generate Embeddings
gen_embeddings("model_name", "Generate embeddings from this prompt").await.expect("Failed to generate embeddings");
// Example: List Models
list_models().await.expect("Failed to list models");
// Example: Push Models
push_models("model_name", true).await.expect("Failed to push model");
}
有关详细 API 文档,请参阅此处。感谢图标:https://www.artstation.com/artwork/n0q6Ye
依赖关系
~6–18MB
~250K SLoC