Build from the current runtime environment.
(
model_api_id: impl Into<String>,
provider_id: impl Into<String>,
working_directory: impl Into<String>,
)
| 125 | impl EnvironmentContext { |
| 126 | /// Build from the current runtime environment. |
| 127 | pub fn from_current( |
| 128 | model_api_id: impl Into<String>, |
| 129 | provider_id: impl Into<String>, |
| 130 | working_directory: impl Into<String>, |
| 131 | ) -> Self { |
| 132 | let wd: String = working_directory.into(); |
| 133 | let is_git = std::path::Path::new(&wd).join(".git").exists(); |
| 134 | Self { |
| 135 | model_api_id: model_api_id.into(), |
| 136 | provider_id: provider_id.into(), |
| 137 | working_directory: wd, |
| 138 | is_git_repo: is_git, |
| 139 | platform: std::env::consts::OS.to_string(), |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | fn trim_for_prompt(input: &str, max_chars: usize) -> (&str, bool) { |