Ollama: Specify keep_alive via settings (#17906)

This commit is contained in:
Peter Tripp 2024-09-16 18:47:25 -04:00 committed by GitHub
parent e66ea9e5d4
commit 67f149a4bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -4,7 +4,7 @@ use gpui::{AnyView, AppContext, AsyncAppContext, ModelContext, Subscription, Tas
use http_client::HttpClient;
use ollama::{
get_models, preload_model, stream_chat_completion, ChatMessage, ChatOptions, ChatRequest,
ChatResponseDelta, OllamaToolCall,
ChatResponseDelta, KeepAlive, OllamaToolCall,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -42,6 +42,8 @@ pub struct AvailableModel {
pub display_name: Option<String>,
/// The Context Length parameter to the model (aka num_ctx or n_ctx)
pub max_tokens: usize,
/// The number of seconds to keep the connection open after the last request
pub keep_alive: Option<KeepAlive>,
}
pub struct OllamaLanguageModelProvider {
@ -156,7 +158,7 @@ impl LanguageModelProvider for OllamaLanguageModelProvider {
name: model.name.clone(),
display_name: model.display_name.clone(),
max_tokens: model.max_tokens,
keep_alive: None,
keep_alive: model.keep_alive.clone(),
},
);
}