Compare commits

...

192 Commits

Author SHA1 Message Date
Richard Feldman
5c563ec303 Delete fetch_fallible for now 2025-12-18 20:29:47 -05:00
Richard Feldman
050b95e429 Clean up imports 2025-12-18 20:29:41 -05:00
Richard Feldman
1385c49e59 Delete ExtensionOperation::AutoInstall for now 2025-12-18 20:29:09 -05:00
Richard Feldman
8a87a7f459 Delete unused fn 2025-12-18 20:28:54 -05:00
Richard Feldman
fc3de7f7f1 use and_then/filter_map over map 2025-12-18 20:28:47 -05:00
Richard Feldman
0482017a95 Restore language_model.rs to origin/main 2025-12-18 20:25:36 -05:00
Richard Feldman
6abc2c2d36 Restore since_v0_8_0.rs to origin/main 2025-12-18 20:24:46 -05:00
Richard Feldman
69bfcb0ed7 Delete openai_migration and open_router_migration 2025-12-18 20:24:25 -05:00
Richard Feldman
38544aef26 Delete open_router_migration.rs 2025-12-18 20:24:01 -05:00
Richard Feldman
ea713e95fe Restore extension_host.rs to origin/main 2025-12-18 20:23:27 -05:00
Richard Feldman
6505bdbb3f Delete other migrations for now 2025-12-18 20:23:17 -05:00
Richard Feldman
0dd773f591 Restore extension_host_proxy.rs to origin/main 2025-12-18 20:22:08 -05:00
Richard Feldman
a638946007 Delete copilot_migration.rs 2025-12-18 20:20:57 -05:00
Richard Feldman
d94ada12d0 Update Cargo.lock 2025-12-18 20:20:27 -05:00
Richard Feldman
387c428720 Restore extension_host Cargo.toml to origin/main 2025-12-18 20:20:22 -05:00
Richard Feldman
9e858de69b Delete llm-provider.wit 2025-12-18 20:19:24 -05:00
Richard Feldman
cb695ce71c Restore the since 0.8.0 stuff to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
39cf37a154 Restore extension_settings.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
be37bd11a7 Restore wasm_host.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
aa8ee02367 Delete some llm provider and oauth stuff 2025-12-18 20:18:17 -05:00
Richard Feldman
005bfdbb96 Restore wit.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
253f7ac4a7 Restore since_v0_6_0.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
0808b636cf Delete since_v0_8_0.rs 2025-12-18 20:18:17 -05:00
Richard Feldman
73f42f0146 Restore test/platform.rs and text_context.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
b4a2dd4c8e Restore api_key.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
3373bad23b Delete ConfigurationViewTargetAgent::EditPrediction 2025-12-18 20:18:17 -05:00
Richard Feldman
0186e9bd42 Delete some unnecessary comments 2025-12-18 20:18:17 -05:00
Richard Feldman
14b337b2db Minimize a git diff 2025-12-18 20:18:17 -05:00
Richard Feldman
ee04ad637f Delete google_ai_api_key.rs 2025-12-18 20:18:17 -05:00
Richard Feldman
347825cc09 Restore anthropic.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
3f20635ff0 Restore google.rs to origin/main, modulo a comment 2025-12-18 20:18:17 -05:00
Richard Feldman
f2a4e081cc Delete allowed_env_var_providers for now 2025-12-18 20:18:17 -05:00
Richard Feldman
ca616d8824 Update Cargo.lock 2025-12-18 20:18:17 -05:00
Richard Feldman
09920413a6 Restore agent.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
3e5621833b Restore crates/settings_ui/Cargo.toml to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
86f7066a1b Revert edit prediction provider changes for now 2025-12-18 20:18:17 -05:00
Richard Feldman
8768d46f2c Restore toggle.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
fe7a1aa921 Remove oauth device flow for now 2025-12-18 20:18:17 -05:00
Richard Feldman
dbc37ba469 Restore workspace.rs to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
b2fe8a7afb Restore configuring-zed.md to origin/main 2025-12-18 20:18:17 -05:00
Richard Feldman
23b862c978 Remove google-ai extension for now 2025-12-18 20:18:17 -05:00
Richard Feldman
3012bb9293 Restore extension_api.rs to origin/main 2025-12-18 20:03:00 -05:00
Richard Feldman
0ed4a12ba7 Restore extension_manifest.rs to origin/main 2025-12-18 20:02:40 -05:00
Richard Feldman
f9a85025ea Restore gemini.rs to origin/main 2025-12-18 20:01:35 -05:00
Richard Feldman
7abca1ccbc restore anthropic.rs to origin/main 2025-12-18 20:00:33 -05:00
Richard Feldman
03a05d14ea Restore model_selector_components to origin/main 2025-12-18 20:00:13 -05:00
Richard Feldman
27719b4aad Combine to_selected_model and is_provider_authenticated 2025-12-18 19:58:35 -05:00
Richard Feldman
d6d7da567a Update Cargo.lock 2025-12-18 19:50:42 -05:00
Richard Feldman
3071e07205 Reset default.json to origin/main 2025-12-18 19:49:31 -05:00
Richard Feldman
acbe8aebfc Reset Cargo.toml to origin/main 2025-12-18 19:49:07 -05:00
Richard Feldman
46b5a6f763 Reset extensions dir to origin/main 2025-12-18 19:48:18 -05:00
Richard Feldman
c4c2a0a027 Merge remote-tracking branch 'origin/main' into register-language-model-extensions 2025-12-18 19:46:43 -05:00
Richard Feldman
9d23e5733c Remove AgentModelIcon 2025-12-18 17:21:15 -05:00
Richard Feldman
3a6e91abcb Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-18 17:20:16 -05:00
Richard Feldman
4f22272b0d Alphabetize auto_install_extensions 2025-12-18 09:14:02 -05:00
Richard Feldman
20d7513c73 Re-add html to auto_install_extensions 2025-12-18 09:13:52 -05:00
Richard Feldman
493f8d59e6 Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-18 09:13:26 -05:00
Zed Zippy
65a395fa9a Autofix 2025-12-17 23:33:12 +00:00
Richard Feldman
ca8279ca79 More Gemini extension fixes 2025-12-17 18:30:07 -05:00
Richard Feldman
19833f0132 More minor Google AI fixes 2025-12-17 15:49:28 -05:00
Richard Feldman
ad0687a987 Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-17 15:18:53 -05:00
Richard Feldman
a51b99216d Revise Google AI extension 2025-12-17 15:14:45 -05:00
Richard Feldman
3de07eaf0c Fix extensions/google-ai/src/google_ai.rs
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-17 14:32:55 -05:00
Richard Feldman
5fa97e8da8 wip override the google_ai extension with the hardcoded implementation
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-17 13:53:20 -05:00
Richard Feldman
6acc4cc038 Merge remote-tracking branch 'origin/main' into provider-extensions
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-17 13:49:15 -05:00
Richard Feldman
6a07fe4e99 Revert "Replace extensions google_ai with the hardcoded one."
This reverts commit 6f05a4b6df.
2025-12-17 13:40:30 -05:00
Richard Feldman
6f05a4b6df Replace extensions google_ai with the hardcoded one.
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-17 13:37:36 -05:00
Richard Feldman
78f9f4a768 Go back to just Gemini for now - delete other extensions
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-12-17 13:36:24 -05:00
Richard Feldman
46dedb3e13 wip fixing anthropic regressions 2025-12-17 13:27:23 -05:00
Richard Feldman
ea5800b322 Revise comment about tiktoken 2025-12-16 09:21:26 -05:00
Richard Feldman
b652196356 clippy 2025-12-16 09:15:11 -05:00
Richard Feldman
155a2d2a1e Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-16 09:10:54 -05:00
Richard Feldman
f182aa43bb Replace OAuth-specific HTTP WIT stuff with generic http alternatives. 2025-12-16 09:04:48 -05:00
Danilo Leal
f783f22e33 Remove unused editor dependency from extension_host 2025-12-15 20:59:41 -03:00
Danilo Leal
6811c57550 Adjust description markdown for built-in providers 2025-12-15 20:53:13 -03:00
Danilo Leal
5739fce607 Remove unnecessary comments from edit prediction setup page 2025-12-15 20:52:39 -03:00
Danilo Leal
f0fc578fe6 Start cleaning up the UI 2025-12-15 20:52:23 -03:00
Richard Feldman
7cbc6fb337 Revise layout of OAuth provider in settings 2025-12-15 15:44:57 -05:00
Richard Feldman
55c9113177 Support OAuth extensions in settings panel 2025-12-15 14:14:37 -05:00
Richard Feldman
98248d5a7a Hide hardcoded Copilot Chat setting if extension is installed 2025-12-15 13:24:03 -05:00
Richard Feldman
8d5b12a6be Don't show (Extension) in provider names 2025-12-15 12:50:04 -05:00
Richard Feldman
aa69a52685 Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-15 11:26:44 -05:00
Richard Feldman
d5e2a2a00c Migrate dev extension credentials too 2025-12-15 10:34:03 -05:00
Richard Feldman
094f514414 Minor change to Copilot visuals 2025-12-15 10:13:09 -05:00
Richard Feldman
5abf968748 Make Copilot login flow look like the builtin one 2025-12-14 21:47:17 -05:00
Richard Feldman
dd455306b2 Show "OpenAI-compatible models" notification 2025-12-14 21:14:24 -05:00
Richard Feldman
dd4d5b5b0c Fix multiple env var migrations 2025-12-14 21:14:04 -05:00
Richard Feldman
cc7799af38 Allow multiple API keys 2025-12-14 20:35:01 -05:00
Richard Feldman
13776b7898 Make provider extensions more closely match current styling 2025-12-14 20:04:30 -05:00
Richard Feldman
67f3b0987a Refactor out a var name 2025-12-12 13:20:38 -05:00
Richard Feldman
6a6b556143 Fix a warning 2025-12-12 12:57:26 -05:00
Richard Feldman
3debec1393 Simplify some path resolving logic 2025-12-12 12:55:57 -05:00
Richard Feldman
bde75bb11a Extract a big string into include_str! 2025-12-12 12:54:57 -05:00
Richard Feldman
eff0105c04 Add a comment explaining port behavior 2025-12-12 12:53:20 -05:00
Richard Feldman
4bbc53b0ee Remove obsolete request-credential from the interface 2025-12-12 12:34:44 -05:00
Richard Feldman
00a62555ec Restore since_v0_6_0.rs to origin/main 2025-12-12 12:28:21 -05:00
Richard Feldman
d1f085c063 Rename oauth to be at the front of oauth_send_http_request 2025-12-12 12:16:30 -05:00
Richard Feldman
73341e51ac Clarify sign-in docs 2025-12-12 11:59:15 -05:00
Richard Feldman
ed111bf528 Revise some docs 2025-12-12 11:58:23 -05:00
Richard Feldman
64966bbecc Require sign_in_button_label 2025-12-12 11:55:31 -05:00
Richard Feldman
fe895c7c97 Reorganize LanguageModelAuthConfig 2025-12-12 11:55:17 -05:00
Richard Feldman
9c2c9ea949 Don't make credential_label optional 2025-12-12 11:54:22 -05:00
Richard Feldman
f46b94635d Don't default some of the model options in the extension 2025-12-12 11:53:17 -05:00
Richard Feldman
b9c8f8b79e Deduplicate icon styling 2025-12-12 11:29:14 -05:00
Richard Feldman
6ac42dde0d Restore some origin/main logic 2025-12-12 11:27:50 -05:00
Richard Feldman
7f51ca3dbb Deduplicate some branches 2025-12-12 11:24:15 -05:00
Richard Feldman
c050b4225a Drop an unnecessary constant 2025-12-12 11:22:41 -05:00
Richard Feldman
b2073af63a Make a match exhaustive and use alternatives 2025-12-12 11:22:08 -05:00
Richard Feldman
a52e4af96d Further icon deduplication 2025-12-12 11:14:04 -05:00
Richard Feldman
35aa3f2207 More icon deduplication 2025-12-12 11:13:07 -05:00
Richard Feldman
1a808c4642 Reduce some icon code duplication 2025-12-12 11:11:52 -05:00
Richard Feldman
fda2688165 Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-12 11:11:43 -05:00
Richard Feldman
7881047432 prettier 2025-12-11 01:25:18 -05:00
Richard Feldman
da9281c4a4 Add missing licenses 2025-12-11 01:25:10 -05:00
Richard Feldman
9cc517e0dd Fix some extension auto install bugs 2025-12-11 00:52:08 -05:00
Richard Feldman
d1390a5b78 Merge remote-tracking branch 'origin/main' into migrate-provider-extensions 2025-12-11 00:26:09 -05:00
Richard Feldman
ee4faede38 Migrate on auto-load 2025-12-11 00:22:38 -05:00
Richard Feldman
8d96a699b3 Revise migration system some more 2025-12-11 00:13:11 -05:00
Richard Feldman
8cfb7471db Minimize how we're tracking migrations 2025-12-10 23:21:14 -05:00
Richard Feldman
def9c87837 Migrate credentials without touching settings 2025-12-10 22:29:48 -05:00
Richard Feldman
0313ab6d41 Change open-router to openrouter in default.json 2025-12-10 22:10:29 -05:00
Richard Feldman
c5329fdff2 Rename extension from open-router to openrouter 2025-12-10 22:09:59 -05:00
Richard Feldman
a676a6895b Remove redundant set_builtin_provider_hiding_fn call 2025-12-10 22:05:03 -05:00
Richard Feldman
3b5d7d7d89 Minor cleanups 2025-12-10 22:04:35 -05:00
Richard Feldman
91f01131b1 Introduce DEBUG_ALLOW_UNPUBLISHED_AUTO_EXTENSIONS 2025-12-10 21:29:10 -05:00
Richard Feldman
5fa5226286 Remove llm_provider_authenticate() 2025-12-10 21:28:58 -05:00
Richard Feldman
ae94007227 Merge remote-tracking branch 'origin/main' into migrate-provider-extensions 2025-12-10 21:13:57 -05:00
Richard Feldman
8f425a1bd5 Fix unused arg 2025-12-10 13:11:30 -05:00
Richard Feldman
743c414e7b Refresh models list after successful auth 2025-12-10 13:10:55 -05:00
Richard Feldman
0fe335efc5 Revise Copilot auth 2025-12-10 13:02:38 -05:00
Richard Feldman
36b95aac4b Debugging extension loading timing and fallbacks 2025-12-10 12:55:41 -05:00
Richard Feldman
b2df70ab58 Clean up extension markdown for settings 2025-12-10 12:55:23 -05:00
Richard Feldman
36293d7dd9 Debugging 2025-12-09 17:04:58 -05:00
Richard Feldman
3ae3e1fce8 Don't use a heuristic for icon path 2025-12-09 14:55:44 -05:00
Richard Feldman
e5f1fc7478 Fix some regressions 2025-12-09 14:48:31 -05:00
Richard Feldman
a4f6076da7 Migrate to extensions with fallback to builtin 2025-12-09 14:14:56 -05:00
Richard Feldman
43726b2620 Restore ai_anthropic icon svg 2025-12-09 12:00:36 -05:00
Richard Feldman
94980ffb49 Reduce duplication in compute_configured_providers 2025-12-09 11:55:37 -05:00
Richard Feldman
22cc731450 Remove some duplication from icon logic 2025-12-09 11:54:58 -05:00
Richard Feldman
d9396373e3 Eliminate more code duplication 2025-12-09 11:54:00 -05:00
Richard Feldman
48002be135 Use | instead of code duplication 2025-12-09 11:53:18 -05:00
Richard Feldman
58db83f8f5 more icon code cleanup 2025-12-09 11:48:06 -05:00
Richard Feldman
0243d5b542 Clean up some more icon code 2025-12-09 11:44:10 -05:00
Richard Feldman
06230327fa Clean up some icon code 2025-12-09 11:44:05 -05:00
Richard Feldman
ca5c8992f9 Merge remote-tracking branch 'origin/main' into migrate-provider-extensions 2025-12-08 20:23:32 -05:00
Richard Feldman
1038e1c2ef Clean up some duplicated code 2025-12-08 16:59:49 -05:00
Richard Feldman
e1fe0b3287 Restore providers, deduplicate if extensions are present 2025-12-08 16:25:41 -05:00
Richard Feldman
a0e10a91bf Merge remote-tracking branch 'origin/main' into migrate-provider-extensions 2025-12-08 15:35:44 -05:00
Richard Feldman
272b1aa4bc Remove obsolete llm_provider_authenticate 2025-12-08 14:46:04 -05:00
Richard Feldman
9ef0537b44 Add the other extensions to auto-install 2025-12-07 23:13:52 -05:00
Richard Feldman
77f1de742b delete hardcoded AI providers in favor of extnesions 2025-12-07 21:31:00 -05:00
Richard Feldman
e054cabd41 Migrate Google AI over to the extension 2025-12-07 20:57:00 -05:00
Richard Feldman
3b95cb5682 Migrate Copilot and Anthropic to extensions 2025-12-07 20:48:42 -05:00
Richard Feldman
c89653bd07 Fix bugs around logging out from provider extensions 2025-12-05 17:07:25 -05:00
Richard Feldman
b90ac2dc07 Fix Drop impl for WasmExtension 2025-12-05 16:21:53 -05:00
Marshall Bowers
c9998541f0 Revert spurious changes to default.json 2025-12-05 13:25:03 -05:00
Marshall Bowers
e2b49b3cd3 Restore blank lines from main 2025-12-05 13:08:30 -05:00
Marshall Bowers
d1e77397c6 Don't make v0.8.0 available on Stable/Preview yet 2025-12-05 13:07:36 -05:00
Richard Feldman
cc5f5e35e4 Clean up some comments 2025-12-05 13:00:19 -05:00
Richard Feldman
7183b8a1cd Fix API key bug 2025-12-05 12:59:19 -05:00
Richard Feldman
b1934fb712 Remove builtin Anthropic provider 2025-12-05 12:11:51 -05:00
Richard Feldman
a198b6c0d1 Use icon in more places 2025-12-05 11:48:11 -05:00
Richard Feldman
8b5b2712c8 Update Cargo.lock 2025-12-05 11:32:58 -05:00
Richard Feldman
4464392e8e Use kebab-case for open-router extension too. 2025-12-05 11:19:10 -05:00
Richard Feldman
a0d3bc31e9 Rename copilot_chat to copilot-chat 2025-12-05 11:15:43 -05:00
Richard Feldman
ccd6672d1a Revert "Remove builtin extensions for now"
This reverts commit 5559726fd7.
2025-12-05 11:13:29 -05:00
Richard Feldman
21de6d35dd Revert "Revert auto-install extensions for now"
This reverts commit 2031ca17e5.
2025-12-05 11:13:22 -05:00
Richard Feldman
2031ca17e5 Revert auto-install extensions for now 2025-12-05 11:06:12 -05:00
Richard Feldman
8b1ce75a57 Move wit extensions into their own module 2025-12-05 10:30:02 -05:00
Richard Feldman
5559726fd7 Remove builtin extensions for now 2025-12-04 17:20:47 -05:00
Richard Feldman
e1a9269921 Delete example provider extension 2025-12-04 17:20:47 -05:00
Richard Feldman
3b6b3ff504 Specify env vars for the builtin extensions 2025-12-04 17:19:35 -05:00
Richard Feldman
aabed94970 Add OAuth via web authentication to llm extensions, migrate copilot 2025-12-04 17:12:55 -05:00
Richard Feldman
2d3a3521ba Add OAuth Web Flow auth option for llm provider extensions 2025-12-04 17:12:55 -05:00
Richard Feldman
a48bd10da0 Add llm extensions to auto_install_extensions 2025-12-04 17:12:55 -05:00
Richard Feldman
fec9525be4 Add env var checkbox 2025-12-04 17:12:23 -05:00
Richard Feldman
bf2b8e999e use fill=black over fill=currentColor 2025-12-04 16:51:47 -05:00
Richard Feldman
63c35d2b00 Use local icons in llm extensions 2025-12-04 16:48:25 -05:00
Richard Feldman
1396c68010 Add svg icons to llm provider extensions 2025-12-04 16:43:49 -05:00
Richard Feldman
fcb3d3dec6 Update a comment 2025-12-04 16:28:29 -05:00
Richard Feldman
f54e7f8c9d Add trailing newlines 2025-12-04 16:18:43 -05:00
Richard Feldman
2a89529d7f Use named fields 2025-12-04 16:17:50 -05:00
Richard Feldman
58207325e2 restore impl Drop for WasmExtension 2025-12-04 16:12:21 -05:00
Richard Feldman
e08ab99e8d Add extensions for LLM providers 2025-12-04 16:03:51 -05:00
Richard Feldman
a95f3f33a4 Clean up debug logging 2025-12-04 12:38:06 -05:00
Richard Feldman
b0767c1b1f Merge remote-tracking branch 'origin/main' into provider-extensions 2025-12-04 12:27:15 -05:00
Richard Feldman
b200e10bc4 Clean up debug statements 2025-12-04 11:30:44 -05:00
Richard Feldman
948905d916 Revise provider extensions for Gemini API 2025-12-03 20:22:10 -05:00
Richard Feldman
04de456373 Use extension-llm- prefix for credential keys 2025-12-03 15:55:10 -05:00
Richard Feldman
e5ce32e936 Add provider extension API key in settings 2025-12-03 14:41:39 -05:00
Richard Feldman
d7caae30de Fix auth and subscriptions for provider extensions 2025-12-03 13:00:53 -05:00
Richard Feldman
c7e77674a1 Initial Claude Opus 4.5 implementation of Provider Extensions 2025-12-02 13:50:00 -05:00
11 changed files with 136 additions and 89 deletions

View File

@@ -3,11 +3,11 @@ use agent_client_protocol::{self as acp};
use anyhow::Result;
use collections::IndexMap;
use gpui::{Entity, SharedString, Task};
use language_model::LanguageModelProviderId;
use language_model::{IconOrSvg, LanguageModelProviderId};
use project::Project;
use serde::{Deserialize, Serialize};
use std::{any::Any, error::Error, fmt, path::Path, rc::Rc, sync::Arc};
use ui::{App, IconName};
use ui::App;
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
@@ -210,21 +210,12 @@ pub trait AgentModelSelector: 'static {
}
}
/// Icon for a model in the model selector.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AgentModelIcon {
/// A built-in icon from Zed's icon set.
Named(IconName),
/// Path to a custom SVG icon file.
Path(SharedString),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AgentModelInfo {
pub id: acp::ModelId,
pub name: SharedString,
pub description: Option<SharedString>,
pub icon: Option<AgentModelIcon>,
pub icon: Option<IconOrSvg>,
}
impl From<acp::ModelInfo> for AgentModelInfo {

View File

@@ -30,7 +30,7 @@ use futures::{StreamExt, future};
use gpui::{
App, AppContext, AsyncApp, Context, Entity, SharedString, Subscription, Task, WeakEntity,
};
use language_model::{IconOrSvg, LanguageModel, LanguageModelProvider, LanguageModelRegistry};
use language_model::{LanguageModel, LanguageModelProvider, LanguageModelRegistry};
use project::{Project, ProjectItem, ProjectPath, Worktree};
use prompt_store::{
ProjectContext, PromptStore, RULES_FILE_NAMES, RulesFileContext, UserRulesContext,
@@ -153,10 +153,7 @@ impl LanguageModels {
id: Self::model_id(model),
name: model.name().0,
description: None,
icon: Some(match provider.icon() {
IconOrSvg::Svg(path) => acp_thread::AgentModelIcon::Path(path),
IconOrSvg::Icon(name) => acp_thread::AgentModelIcon::Named(name),
}),
icon: Some(provider.icon()),
}
}
@@ -1633,9 +1630,7 @@ mod internal_tests {
id: acp::ModelId::new("fake/fake"),
name: "Fake".into(),
description: None,
icon: Some(acp_thread::AgentModelIcon::Named(
ui::IconName::ZedAssistant
)),
icon: Some(language_model::IconOrSvg::Icon(ui::IconName::ZedAssistant)),
}]
)])
);

View File

@@ -1,6 +1,6 @@
use std::{cmp::Reverse, rc::Rc, sync::Arc};
use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelList, AgentModelSelector};
use acp_thread::{AgentModelInfo, AgentModelList, AgentModelSelector};
use agent_client_protocol::ModelId;
use agent_servers::AgentServer;
use agent_settings::AgentSettings;
@@ -13,6 +13,7 @@ use gpui::{
Action, AsyncWindowContext, BackgroundExecutor, DismissEvent, FocusHandle, Task, WeakEntity,
};
use itertools::Itertools;
use language_model::IconOrSvg;
use ordered_float::OrderedFloat;
use picker::{Picker, PickerDelegate};
use settings::Settings;
@@ -351,8 +352,8 @@ impl PickerDelegate for AcpModelPickerDelegate {
.child(
ModelSelectorListItem::new(ix, model_info.name.clone())
.map(|this| match &model_info.icon {
Some(AgentModelIcon::Path(path)) => this.icon_path(path.clone()),
Some(AgentModelIcon::Named(icon)) => this.icon(*icon),
Some(IconOrSvg::Svg(path)) => this.icon_path(path.clone()),
Some(IconOrSvg::Icon(icon)) => this.icon(*icon),
None => this,
})
.is_selected(is_selected)

View File

@@ -1,11 +1,12 @@
use std::rc::Rc;
use std::sync::Arc;
use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelSelector};
use acp_thread::{AgentModelInfo, AgentModelSelector};
use agent_servers::AgentServer;
use agent_settings::AgentSettings;
use fs::Fs;
use gpui::{Entity, FocusHandle};
use language_model::IconOrSvg;
use picker::popover_menu::PickerPopoverMenu;
use settings::Settings as _;
use ui::{ButtonLike, KeyBinding, PopoverMenuHandle, TintColor, Tooltip, prelude::*};
@@ -127,8 +128,8 @@ impl Render for AcpModelSelectorPopover {
.when_some(model_icon, |this, icon| {
this.child(
match icon {
AgentModelIcon::Path(path) => Icon::from_external_svg(path),
AgentModelIcon::Named(icon_name) => Icon::new(icon_name),
IconOrSvg::Svg(path) => Icon::from_external_svg(path),
IconOrSvg::Icon(icon_name) => Icon::new(icon_name),
}
.color(color)
.size(IconSize::XSmall),

View File

@@ -361,33 +361,52 @@ fn init_language_model_settings(cx: &mut App) {
fn update_active_language_model_from_settings(cx: &mut App) {
let settings = AgentSettings::get_global(cx);
fn to_selected_model(selection: &LanguageModelSelection) -> language_model::SelectedModel {
language_model::SelectedModel {
provider: LanguageModelProviderId::from(selection.provider.0.clone()),
model: LanguageModelId::from(selection.model.clone()),
fn to_selected_model(
selection: &LanguageModelSelection,
registry: &LanguageModelRegistry,
cx: &App,
) -> Option<language_model::SelectedModel> {
let provider_id = LanguageModelProviderId::from(selection.provider.0.clone());
if registry
.provider(&provider_id)
.map_or(false, |provider| provider.is_authenticated(cx))
{
Some(language_model::SelectedModel {
provider: LanguageModelProviderId::from(selection.provider.0.clone()),
model: LanguageModelId::from(selection.model.clone()),
})
} else {
None
}
}
let default = settings.default_model.as_ref().map(to_selected_model);
let registry = LanguageModelRegistry::global(cx);
let registry_ref = registry.read(cx);
let default = settings
.default_model
.as_ref()
.and_then(|s| to_selected_model(s, registry_ref, cx));
let inline_assistant = settings
.inline_assistant_model
.as_ref()
.map(to_selected_model);
.and_then(|s| to_selected_model(s, registry_ref, cx));
let commit_message = settings
.commit_message_model
.as_ref()
.map(to_selected_model);
.and_then(|s| to_selected_model(s, registry_ref, cx));
let thread_summary = settings
.thread_summary_model
.as_ref()
.map(to_selected_model);
.and_then(|s| to_selected_model(s, registry_ref, cx));
let inline_alternatives = settings
.inline_alternatives
.iter()
.map(to_selected_model)
.filter_map(|s| to_selected_model(s, registry_ref, cx))
.collect::<Vec<_>>();
LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
registry.update(cx, |registry, cx| {
registry.select_default_model(default.as_ref(), cx);
registry.select_inline_assistant_model(inline_assistant.as_ref(), cx);
registry.select_commit_message_model(commit_message.as_ref(), cx);

View File

@@ -2,10 +2,9 @@ use std::{cmp::Reverse, sync::Arc};
use agent_settings::AgentSettings;
use collections::{HashMap, HashSet, IndexMap};
use futures::{StreamExt, channel::mpsc};
use fuzzy::{StringMatch, StringMatchCandidate, match_strings};
use gpui::{
Action, AnyElement, App, BackgroundExecutor, DismissEvent, FocusHandle, Subscription, Task,
};
use gpui::{Action, AnyElement, App, BackgroundExecutor, DismissEvent, FocusHandle, Task};
use language_model::{
AuthenticateError, ConfiguredModel, IconOrSvg, LanguageModel, LanguageModelId,
LanguageModelProvider, LanguageModelProviderId, LanguageModelRegistry,
@@ -76,7 +75,7 @@ fn all_models(cx: &App) -> GroupedModels {
})
.collect();
let all = providers
let all: Vec<ModelInfo> = providers
.iter()
.flat_map(|provider| {
provider
@@ -124,7 +123,7 @@ pub struct LanguageModelPickerDelegate {
filtered_entries: Vec<LanguageModelPickerEntry>,
selected_index: usize,
_authenticate_all_providers_task: Task<()>,
_subscriptions: Vec<Subscription>,
_refresh_models_task: Task<()>,
popover_styles: bool,
focus_handle: FocusHandle,
}
@@ -151,24 +150,42 @@ impl LanguageModelPickerDelegate {
get_active_model: Arc::new(get_active_model),
on_toggle_favorite: Arc::new(on_toggle_favorite),
_authenticate_all_providers_task: Self::authenticate_all_providers(cx),
_subscriptions: vec![cx.subscribe_in(
&LanguageModelRegistry::global(cx),
window,
|picker, _, event, window, cx| {
match event {
language_model::Event::ProviderStateChanged(_)
| language_model::Event::AddedProvider(_)
| language_model::Event::RemovedProvider(_) => {
let query = picker.query(cx);
picker.delegate.all_models = Arc::new(all_models(cx));
// Update matches will automatically drop the previous task
// if we get a provider event again
picker.update_matches(query, window, cx)
}
_ => {}
_refresh_models_task: {
// Create a channel to signal when models need refreshing
let (refresh_tx, mut refresh_rx) = mpsc::unbounded::<()>();
// Subscribe to registry events and send refresh signals through the channel
let registry = LanguageModelRegistry::global(cx);
cx.subscribe(&registry, move |_picker, _, event, _cx| match event {
language_model::Event::ProviderStateChanged(_)
| language_model::Event::AddedProvider(_)
| language_model::Event::RemovedProvider(_)
| language_model::Event::ProvidersChanged => {
refresh_tx.unbounded_send(()).ok();
}
},
)],
language_model::Event::DefaultModelChanged
| language_model::Event::InlineAssistantModelChanged
| language_model::Event::CommitMessageModelChanged
| language_model::Event::ThreadSummaryModelChanged => {}
})
.detach();
// Spawn a task that listens for refresh signals and updates the picker
cx.spawn_in(window, async move |this, cx| {
while let Some(()) = refresh_rx.next().await {
if this
.update_in(cx, |picker, window, cx| {
picker.delegate.all_models = Arc::new(all_models(cx));
picker.refresh(window, cx);
})
.is_err()
{
// Picker was dropped, exit the loop
break;
}
}
})
},
popover_styles,
focus_handle,
}

View File

@@ -255,6 +255,21 @@ async fn copy_extension_resources(
}
}
for (_, provider_entry) in &manifest.language_model_providers {
if let Some(icon_path) = &provider_entry.icon {
let source_icon = extension_path.join(icon_path);
let dest_icon = output_dir.join(icon_path);
// Create parent directory if needed
if let Some(parent) = dest_icon.parent() {
fs::create_dir_all(parent)?;
}
fs::copy(&source_icon, &dest_icon)
.with_context(|| format!("failed to copy LLM provider icon '{}'", icon_path))?;
}
}
if !manifest.languages.is_empty() {
let output_languages_dir = output_dir.join("languages");
fs::create_dir_all(&output_languages_dir)?;

View File

@@ -12,12 +12,11 @@ pub mod provider;
mod settings;
pub use crate::extension::init_proxy as init_extension_proxy;
use crate::provider::anthropic::AnthropicLanguageModelProvider;
use crate::provider::bedrock::BedrockLanguageModelProvider;
use crate::provider::cloud::CloudLanguageModelProvider;
use crate::provider::copilot_chat::CopilotChatLanguageModelProvider;
use crate::provider::google::GoogleLanguageModelProvider;
pub use crate::provider::google::GoogleLanguageModelProvider;
use crate::provider::lmstudio::LmStudioLanguageModelProvider;
pub use crate::provider::mistral::MistralLanguageModelProvider;
use crate::provider::ollama::OllamaLanguageModelProvider;
@@ -38,36 +37,41 @@ pub fn init(user_store: Entity<UserStore>, client: Arc<Client>, cx: &mut App) {
if let Some(extension_store) = extension_host::ExtensionStore::try_global(cx) {
cx.subscribe(&extension_store, {
let registry = registry.clone();
move |extension_store, event, cx| match event {
extension_host::Event::ExtensionInstalled(extension_id) => {
if let Some(manifest) = extension_store
.read(cx)
.extension_manifest_for_id(extension_id)
{
if !manifest.language_model_providers.is_empty() {
registry.update(cx, |registry, cx| {
registry.extension_installed(extension_id.clone(), cx);
});
move |extension_store, event, cx| {
match event {
extension_host::Event::ExtensionInstalled(extension_id) => {
// Check if this extension has language_model_providers
if let Some(manifest) = extension_store
.read(cx)
.extension_manifest_for_id(extension_id)
{
if !manifest.language_model_providers.is_empty() {
registry.update(cx, |registry, cx| {
registry.extension_installed(extension_id.clone(), cx);
});
}
}
}
}
extension_host::Event::ExtensionUninstalled(extension_id) => {
registry.update(cx, |registry, cx| {
registry.extension_uninstalled(extension_id, cx);
});
}
extension_host::Event::ExtensionsUpdated => {
let mut new_ids = HashSet::default();
for (extension_id, entry) in extension_store.read(cx).installed_extensions() {
if !entry.manifest.language_model_providers.is_empty() {
new_ids.insert(extension_id.clone());
}
extension_host::Event::ExtensionUninstalled(extension_id) => {
registry.update(cx, |registry, cx| {
registry.extension_uninstalled(extension_id, cx);
});
}
registry.update(cx, |registry, cx| {
registry.sync_installed_llm_extensions(new_ids, cx);
});
extension_host::Event::ExtensionsUpdated => {
// Re-sync installed extensions on bulk updates
let mut new_ids = HashSet::default();
for (extension_id, entry) in extension_store.read(cx).installed_extensions()
{
if !entry.manifest.language_model_providers.is_empty() {
new_ids.insert(extension_id.clone());
}
}
registry.update(cx, |registry, cx| {
registry.sync_installed_llm_extensions(new_ids, cx);
});
}
_ => {}
}
_ => {}
}
})
.detach();

View File

@@ -996,7 +996,7 @@ pub fn get_bedrock_tokens(
}
}
// Tiktoken doesn't yet support these models, so we manually use the
// Tiktoken doesn't support these models, so we manually use the
// same tokenizer as GPT-4.
tiktoken_rs::num_tokens_from_messages("gpt-4", &string_messages)
.map(|tokens| (tokens + tokens_from_images) as u64)

View File

@@ -707,7 +707,7 @@ pub fn count_google_tokens(
})
.collect::<Vec<_>>();
// Tiktoken doesn't yet support these models, so we manually use the
// Tiktoken doesn't support these models, so we manually use the
// same tokenizer as GPT-4.
tiktoken_rs::num_tokens_from_messages("gpt-4", &messages).map(|tokens| tokens as u64)
})

View File

@@ -564,6 +564,11 @@ pub fn main() {
dap_adapters::init(cx);
auto_update_ui::init(cx);
reliability::init(client.clone(), cx);
// Initialize the language model registry first, then set up the extension proxy
// BEFORE extension_host::init so that extensions can register their LLM providers
// when they load.
language_model::init(app_state.client.clone(), cx);
language_models::init_extension_proxy(cx);
extension_host::init(
extension_host_proxy.clone(),
app_state.fs.clone(),
@@ -589,7 +594,6 @@ pub fn main() {
cx,
);
supermaven::init(app_state.client.clone(), cx);
language_model::init(app_state.client.clone(), cx);
language_models::init(app_state.user_store.clone(), app_state.client.clone(), cx);
acp_tools::init(cx);
edit_prediction_ui::init(cx);