MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / fetch

Method fetch

crates/opencode-provider/src/models.rs:136–161  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

134 }
135
136 async fn fetch(&self) -> ModelsData {
137 let url = format!("{}/api.json", MODELS_DEV_URL);
138
139 match reqwest::Client::new()
140 .get(&url)
141 .header("User-Agent", "opencode-rust")
142 .timeout(std::time::Duration::from_secs(10))
143 .send()
144 .await
145 {
146 Ok(response) if response.status().is_success() => match response.text().await {
147 Ok(text) => {
148 if let Ok(parsed) = serde_json::from_str::<ModelsData>(&text) {
149 let _ = tokio::fs::write(&self.cache_path, &text).await;
150 let mut data = self.data.write().await;
151 *data = Some(parsed.clone());
152 return parsed;
153 }
154 }
155 _ => {}
156 },
157 _ => {}
158 }
159
160 HashMap::new()
161 }
162
163 pub async fn refresh(&self) {
164 self.fetch().await;

Callers 2

loadMethod · 0.45
refreshMethod · 0.45

Calls 6

newFunction · 0.85
sendMethod · 0.45
getMethod · 0.45
statusMethod · 0.45
textMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected