81 lines
1.8 KiB
Rust
81 lines
1.8 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::dto::api;
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct OllamaModels {
|
|
pub models: Vec<OllamaModel>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct OllamaModel {
|
|
pub name: String,
|
|
|
|
pub details: Option<OllamaModelDetails>,
|
|
|
|
pub size: Option<u64>,
|
|
pub digest: Option<String>,
|
|
pub modified_at: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct OllamaModelDetails {
|
|
pub family: Option<String>,
|
|
pub parameter_size: Option<String>,
|
|
pub quantization_level: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct OllamaOptions {
|
|
pub temperature: Option<f32>,
|
|
pub top_p: Option<f32>,
|
|
pub top_k: Option<u32>,
|
|
pub repeat_penalty: Option<f32>,
|
|
pub seed: Option<i64>,
|
|
|
|
pub num_ctx: Option<u32>,
|
|
pub num_predict: Option<u32>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct OllamaGenerateRequest<'a> {
|
|
pub model: &'a str,
|
|
pub prompt: &'a str,
|
|
pub stream: bool,
|
|
pub options: OllamaOptions,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct OllamaGenerateResponse {
|
|
pub model: String,
|
|
pub created_at: Option<String>,
|
|
pub response: String,
|
|
pub done: bool,
|
|
|
|
#[serde(default)]
|
|
pub context: Option<Vec<u64>>,
|
|
|
|
pub total_duration: Option<u64>,
|
|
pub load_duration: Option<u64>,
|
|
pub prompt_eval_count: Option<u32>,
|
|
pub eval_count: Option<u32>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct OllamaChatRequest<'a> {
|
|
pub model: &'a str,
|
|
pub messages: &'a [api::Message],
|
|
pub stream: bool,
|
|
pub options: OllamaOptions,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct OllamaChatResponse {
|
|
pub model: String,
|
|
pub message: api::Message,
|
|
pub done: bool,
|
|
|
|
pub prompt_eval_count: Option<u32>,
|
|
pub eval_count: Option<u32>,
|
|
}
|