Commit graph

262 commits

Author SHA1 Message Date
Marshall Bowers
5dcd0d37a6
language_models: Denote Copilot Chat as not supporting tools (#27909)
This PR updates the Copilot Chat language model to indicate it does not
yet support tool use in Zed.

Release Notes:

- N/A
2025-04-02 12:12:09 +00:00
Bennet Bo Fenner
b158ee60ca
Fix Gemini function calling (#27905)
This seems to improve the performance of `gemini-2.5-pro-exp-03-25`
significantly.
We know define a single `Tool` that has multiple `FunctionDeclaration`s,
instead of defining multiple `Tool`s with a single
`FunctionDeclaration`.
Oddly enough the `flash` models seemed to work perfectly fine with the
multiple `Tool { ... }` definitions

Release Notes:

- N/A
2025-04-02 10:35:17 +00:00
Danilo Leal
192097f58f
assistant2: Ensure errors are also displayed in populated new thread view (#27869)
Follow-up to https://github.com/zed-industries/zed/pull/27812

This PR makes sure these errors cases also show up in the panel's empty
state even when there is past data.

| No ToS | Missing Provider |
|--------|--------|
| ![CleanShot 2025-04-01 at 4  49
36@2x](https://github.com/user-attachments/assets/6da6bdc9-daa6-4a7b-a224-989eb845e205)
| ![CleanShot 2025-04-01 at 4  50
04@2x](https://github.com/user-attachments/assets/bddf62cb-3727-44b5-b115-9a88313c6d85)
|

Release Notes:

- N/A
2025-04-01 17:06:34 -03:00
Marshall Bowers
5880271b11
language_model: Add supports_tools method to LanguageModel (#27867)
This PR adds a new `supports_tools` method to the `LanguageModel` trait
to indicate whether a given model supports tool use.

Release Notes:

- N/A
2025-04-01 19:56:05 +00:00
Bennet Bo Fenner
5509e0141a
Return language model events when using Google model via zed.dev (#27831)
Release Notes:

- N/A
2025-04-01 08:58:17 +00:00
Danilo Leal
dce824f095
assistant2: Refine empty states design (#27812)
| No LLM provider | Fresh Start | No ToS |
|--------|--------|--------|
| ![CleanShot 2025-03-31 at 7  04
17@2x](https://github.com/user-attachments/assets/aab5987c-1530-401d-acc6-65e4f2fc13b8)
| ![CleanShot 2025-03-31 at 7  04
39@2x](https://github.com/user-attachments/assets/b2c7a2e0-5178-4bcb-a917-da7bf8e6246c)
| ![CleanShot 2025-03-31 at 7  05
10@2x](https://github.com/user-attachments/assets/4a656e82-0e1d-4d11-8d34-8eeeadd4814c)
|

Release Notes:

- N/A
2025-03-31 19:31:56 -03:00
Piotr Osiewicz
dc64ec9cc8
chore: Bump Rust edition to 2024 (#27800)
Follow-up to https://github.com/zed-industries/zed/pull/27791

Release Notes:

- N/A
2025-03-31 20:55:27 +02:00
Piotr Osiewicz
0729d24d77
chore: Prepare for Rust edition bump to 2024 (without autofix) (#27791)
Successor to #27779 - in this PR I've applied changes manually, without
futzing with if let lifetimes at all.

Release Notes:

- N/A
2025-03-31 20:10:36 +02:00
Bennet Bo Fenner
01a2c8eb01
Set tool schema format for zed.dev language model (#27788)
Release Notes:

- N/A
2025-03-31 16:49:59 +00:00
Bennet Bo Fenner
c8a9a74e6a
Add tool calling support for Gemini models (#27772)
Release Notes:

- N/A
2025-03-31 17:46:42 +02:00
Richard Feldman
85740ddaa4
Make serialization backwards-compatible for collab server (#27626)
Sets up the collab server to accept the format of system message that
we'll introduce later for [prompt
caching](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching).

Release Notes:

- N/A
2025-03-27 18:20:10 -04:00
Richard Feldman
76d3a9a0f0
Retry on 5xx errors from cloud language model providers (#27584)
Release Notes:

- N/A
2025-03-27 09:35:16 -04:00
isomo
baf03e355b
copilot: Add Claude 3.7-Sonnet-Thought model to Copilot Chat (#27409)
- Follow-up to: #25529 

Release Notes:

- Added Claude Sonnet 3.7 Thought to GitHub Copilot Chat
2025-03-25 10:56:27 +01:00
Bennet Bo Fenner
a52e2f9553
Show claude-3-7-sonnet-thinking model for all users (#27256)
Release Notes:

- N/A
2025-03-21 17:23:36 +01:00
Bennet Bo Fenner
a709d4c7c6
assistant: Add support for claude-3-7-sonnet-thinking (#27085)
Closes #25671

Release Notes:

- Added support for `claude-3-7-sonnet-thinking` in the assistant panel

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
2025-03-21 12:29:07 +00:00
Mikayla Maki
1aefa5178b
Move "async move" a few characters to the left in cx.spawn() (#26758)
This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
2025-03-19 02:09:02 +00:00
Smit Barmase
6a95ec6a64
copilot: Decouple copilot sign in from edit prediction settings (#26689)
Closes #25883

This PR allows you to use copilot chat for assistant without setting
copilot as the edit prediction provider.


[copilot.webm](https://github.com/user-attachments/assets/fecfbde1-d72c-4c0c-b080-a07671fb846e)

Todos:
- [x] Remove redudant "copilot" key from settings
- [x] Do not disable copilot LSP when `edit_prediction_provider` is not
set to `copilot`
- [x] Start copilot LSP when:
  - [x]  `edit_prediction_provider` is set to `copilot`
  - [x] Copilot sign in clicked from assistant settings
- [x] Handle flicker for frame after starting LSP, but before signing in
caused due to signed out status
- [x] Fixed this by adding intermediate state for awaiting signing in in
sign out enum
- [x] Handle cancel button should sign out from `copilot` (existing bug)
- [x] Handle modal dismissal should sign out if not in signed in state
(existing bug)

Release Notes:

- You can now sign into Copilot from assistant settings without making
it your edit prediction provider. This is useful if you want to use
Copilot chat while keeping a different provider, like Zed, for
predictions.
- Removed the `copilot` key from `features` in settings. Use
`edit_prediction_provider` instead.
2025-03-14 15:10:56 +05:30
Michael Sloan
8e0e291bd5
Track cumulative token usage in assistant2 when using anthropic API (#26738)
Release Notes:

- N/A
2025-03-13 22:56:16 +00:00
Smit Barmase
5aae3bdc69
copilot: Fix missing sign-out button when Zed is the edit prediction provider (#26340)
Closes #25884

Added a sign-out button for Copilot in Assistant settings, allowing
sign-out even when copilot is disabled.

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/43fc97ad-f73c-49e1-a7b6-a3910434d661"
/>



Release Notes:

- Added a sign-out button for Copilot in Assistant settings.
2025-03-09 21:39:14 +05:30
Marshall Bowers
97c0a0a86e
language_models: Remove .unwraps in Bedrock provider (#26238)
This PR removes a number of `.unwrap`s in the Bedrock provider.

We must not `.unwrap` in situations where it is not provably safe to do
so, which it was not in any of these cases.

Release Notes:

- Fixed some potential panics in the AWS Bedrock model provider.
2025-03-06 21:02:37 +00:00
Marshall Bowers
aceab76ae4
gpui: Rename rounded_md to rounded_sm (#26228)
This PR renames the `rounded_md` style method to `rounded_sm`.

Follow up to https://github.com/zed-industries/zed/pull/26221, which
freed up the `rounded_sm` name.

Release Notes:

- N/A
2025-03-06 17:57:31 +00:00
Marshall Bowers
d0c2bef8c3
anthropic: Use an empty object if no tool input is provided (#26144)
This PR changes the default value when no input is provided with a tool
use from `null` to `{}`.

This fixes an issue I was seeing where tools that didn't accept input
were not being called correctly.

Release Notes:

- N/A
2025-03-05 19:17:44 +00:00
Danilo Leal
508b581215
assistant: Refine settings view's instruction visuals (#25812)
I've been bothered by using simple hyphens for bullet lists here for a
while; it kinda looked cheap and not well-formatted. So, in this PR, I'm
adding a new, custom UI component in the `language_models` crate, called
`InstructionListItem`, based off the `ListItem` that's somewhat
mimic'ing what a `<li>` would be on the web.

It does have a "rigid" structure as in it's always a label followed by a
button (which is optional), but that seems okay given it has been the
overall shape of the copy we've been using here. Also, never really
loved that we were pasting URLs directly, that kinda felt cheap, too. I
could see an argument where it's just clearer, but it looks too
cluttered, as URLs aren't super pretty, necessarily.

| Before | After |
|--------|--------|
| <img
src="https://github.com/user-attachments/assets/ffd1ac27-b1f4-450d-abf5-079285fc9877"
width="700px" /> | <img
src="https://github.com/user-attachments/assets/28fb9d0d-205d-45d8-9e43-1aaa947adc96"
width="700px" /> |

Release Notes:

- N/A
2025-02-28 12:06:47 -03:00
Shardul Vaidya
6092918be8
assistant: Improve Amazon Bedrock configuration instructions (#25699) 2025-02-27 21:36:41 -03:00
Danilo Leal
5c400dac8d
assistant2: Adjust empty state layout (#25745)
Going for a different, arguably simpler design for the Assistant 2 empty
state here. Also took the opportunity to adjust other elements like the
toolbar, message editor, and some items in the configuration page.

<img
src="https://github.com/user-attachments/assets/03fd1d48-a675-4eac-b694-bbe4eeaf06e9"
width="700px"/>

Release Notes:

- N/A
2025-02-27 11:33:53 -03:00
Marshall Bowers
e7df5ce61c
assistant2: Avoid unnecessary String cloning in tool use (#25725)
This PR removes some unnecessary `String` cloning in the tool use paths.

We now store the data in `Arc<str>`s for cheap cloning.

Release Notes:

- N/A
2025-02-27 03:16:09 +00:00
Shardul Vaidya
11838cf89e
bedrock: Fix region bug (#25716)
Closes #25714

Internal team reported issue where the Bedrock provider defaulted to
"us-east-1" for all requests regardless of what is configured in the
credentials until first zed restart.

Release Notes:

- Fixed an issue where the Bedrock model provider would not always
respect the region.
2025-02-26 20:55:03 -05:00
Marshall Bowers
d82a132477
language_model: Use LanguageModelToolUseId instead of a String (#25666)
This PR updates the `LanguageModelToolResult` type to use a
`LanguageModelToolUseId` for the tool use ID instead of a `String`.

Release Notes:

- N/A
2025-02-26 17:34:16 +00:00
Marshall Bowers
75dbe189bd
Give Zed AI users access to Claude 3.7 Sonnet (#25577)
This PR updates the client-side checks to give Zed AI users access to
Claude 3.7 Sonnet.

Requires https://github.com/zed-industries/zed/pull/25576 to be
deployed.

Release Notes:

- Added support for Claude 3.7 Sonnet to Zed AI.
2025-02-25 12:15:15 -05:00
zhaopeng
b12b8340de
copilot: Add Claude 3.7 Sonnet to Copilot Chat (#25529)
- Follow-up to: https://github.com/zed-industries/zed/issues/25488

Co-authored-by: Peter Tripp <peter@zed.dev>
2025-02-25 15:51:55 +00:00
Marshall Bowers
21fc3c07b6
language_models: Store Bedrock credentials under https://amazonaws.com in the keychain (#25565)
This PR updates the Bedrock provider to store the AWS credentials under
`https://amazonaws.com` in the keychain.

Release Notes:

- N/A
2025-02-25 15:32:27 +00:00
Shardul Vaidya
eda233344c
assistant: Add Bedrock support (#21092)
Closes #16544

Release Notes:

- Added support for AWS Bedrock to the Assistant.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-24 18:10:12 -05:00
Marshall Bowers
def342e35c
Remove dependents of language_models (#25511)
This PR removes the dependents of the `language_models` crate.

The following types have been moved from `language_models` to
`language_model` to facilitate this:

- `LlmApiToken`
- `RefreshLlmTokenListener`
- `MaxMonthlySpendReachedError`
- `PaymentRequiredError`

With this change only `zed` now depends on `language_models`.

Release Notes:

- N/A
2025-02-24 22:46:45 +00:00
Marshall Bowers
e5b97a5e48
Move report_assistant_event into language_model crate (#25508)
This PR moves the `report_assistant_event` function from the
`language_models` crate to the `language_model` crate.

This allows us to drop some dependencies on `language_models`.

Release Notes:

- N/A
2025-02-24 22:27:26 +00:00
Marshall Bowers
0acd556106
language_model: Remove dependencies on individual model provider crates (#25503)
This PR removes the dependencies on the individual model provider crates
from the `language_model` crate.

The various conversion methods for converting a `LanguageModelRequest`
into its provider-specific request type have been inlined into the
various provider modules in the `language_models` crate.

The model providers we provide via Zed's cloud offering get to stay, for
now.

Release Notes:

- N/A
2025-02-24 16:41:35 -05:00
Antonio Scandurra
f517050548
Partially fix assistant onboarding (#25313)
While investigating #24896, I noticed two issues:

1. The default configuration for the `zed.dev` provider was using the
wrong string for Claude 3.5 Sonnet. This meant the provider would always
result as not configured until the user selected it from the model
picker, because we couldn't deserialize that string to a valid
`anthropic::Model` enum variant.
2. When clicking on `Open New Chat`/`Start New Thread` in the provider
configuration, we would select `Claude 3.5 Haiku` by default instead of
Claude 3.5 Sonnet.

Release Notes:

- Fixed some issues that caused AI providers to sometimes be
misconfigured.
2025-02-24 07:29:55 +00:00
Marshall Bowers
21bb7242ea
Add CredentialsProvider to silence keychain prompts in development (#25266)
This PR adds a new `CredentialsProvider` trait that abstracts over
interacting with the system keychain.

We had previously introduced a version of this scoped just to Zed auth
in https://github.com/zed-industries/zed/pull/11505.

However, after landing https://github.com/zed-industries/zed/pull/25123,
we now have a similar issue with the credentials for language model
providers that are also stored in the keychain (and thus also produce a
spam of popups when running a development build of Zed).

This PR takes the existing approach and makes it more generic, such that
we can use it everywhere that we need to read/store credentials in the
keychain.

There are still two credential provider implementations:

- `KeychainCredentialsProvider` will interact with the system keychain
(using the existing GPUI APIs)
- `DevelopmentCredentialsProvider` will use a local file on the file
system

We only use the `DevelopmentCredentialsProvider` when:

1. We are running a development build of Zed
2. The `ZED_DEVELOPMENT_AUTH` environment variable is set
- I am considering removing the need for this and making it the default,
but that will be explored in a follow-up PR.

Release Notes:

- N/A
2025-02-20 17:58:50 +00:00
Marshall Bowers
7a6b652ebc
language_model: Return AuthenticateErrors from LanguageModelProvider::authenticate (#25126)
This PR updates the `LanguageModelProvider::authenticate` method to
return an `AuthenticateError` instead of an `anyhow::Error`.

This allows us to model the "credentials not found" state explicitly as
`AuthenticateError::CredentialsNotFound`, which enables the caller to
check for this state and act accordingly.

Planning to use this in #25123 to silence errors about missing
credentials when authenticating providers in the background.

Release Notes:

- N/A
2025-02-19 00:01:48 +00:00
Michael Sloan
b1872e3afd
cx.background_executor().spawn(...) -> cx.background_spawn(...) (#25103)
Done automatically with

> ast-grep -p '$A.background_executor().spawn($B)' -r
'$A.background_spawn($B)' --update-all --globs "\!crates/gpui"

Followed by:

* `cargo fmt`
* Unexpected need to remove some trailing whitespace.
* Manually adding imports of `gpui::{AppContext as _}` which provides
`background_spawn`
* Added `AppContext as _` to existing use of `AppContext`

Release Notes:

- N/A
2025-02-18 20:30:33 +00:00
Richard Hao
f833a01a7e
copilot: Add support for Gemini 2.0 Flash model to Copilot Chat (#24952)
Co-authored-by: Peter Tripp <peter@zed.dev>
2025-02-17 19:25:38 +00:00
Shidfar Hodizoda
7ee492746d
assistant: Add Mistral support (#24879)
Closes #12519.

Release Notes:

- Added support for Mistral to the Assistant.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-14 13:07:41 -05:00
Marshall Bowers
888a2df3f0
Sort Cargo.tomls (#24417)
This PR sorts the dependencies in a number of `Cargo.toml` files.

Release Notes:

- N/A
2025-02-07 02:14:57 +00:00
Peter Tripp
2f82374926
Switch GitHub Copilot Chat from o1-mini to o3-mini (#24080)
Co-authored-by: SkywardSyntax <87048477+SkywardSyntax@users.noreply.github.com>
2025-02-01 12:49:24 -05:00
Roshan Padaki
af461f8165
assistant: Use GPT 4 tokenizer for o3-mini (#24068)
Sorry to dump an unsolicited PR for a hot feature! I'm sure someone else
was taking a look at this.

I noticed that token counting was disabled and I was getting error logs
of the form `[2025-01-31T22:59:01-05:00 ERROR assistant_context_editor]
No tokenizer found for model o3-mini` when using the new model. To fix
the issue, this PR registers the `gpt-4` tokenizer for this model.

Release Notes:

- openai: Fixed Assistant token counts for `o3-mini` models
2025-02-01 12:08:44 -05:00
Jason Lee
706f7be5e7
gpui: Add line_clamp to truncate text after a specified number of lines (#23058)
Release Notes:

- N/A

Add this feature for some case we need keep 2 or 3 lines, but truncate.
For example the blog post summary.

- Added `line_clamp` method.
    Ref: https://tailwindcss.com/docs/line-clamp


## Break changes:

- Renamed `gpui::Truncate` to `gpui::TextOverflow` to match
[CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow).
- Update `truncate` style method to match [Tailwind
CSS](https://tailwindcss.com/docs/text-overflow) behavior:

    ```css
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    ```
<img width="538" alt="image"
src="https://github.com/user-attachments/assets/c69c4213-eac9-4087-9daa-ce7afe18c758"
/>


## Show case

<img width="816" alt="image"
src="https://github.com/user-attachments/assets/e0660290-8042-4954-b93c-c729d609484a"
/>

![CleanShot 2025-01-13 at 17 22
05](https://github.com/user-attachments/assets/38644892-79fe-4254-af9e-88c1349561bd)

## Describe changes

The [second
commit](6b41c2772f)
for make sure text layout to match with the line clamp. Before this
change, they may wrap many lines in sometimes. And I also make
line_clamp default to 1 if we used `truncate` to ensure no wrap.

> TODO: There is still a tiny detail that is not easy to fix. This
problem only occurs in the case of certain long words. I will think
about how to improve it later. At present, this has some flaws but does
not affect the use.
2025-01-29 22:14:24 +02:00
Danilo Leal
f8dddf0a5c
assistant2: Tweak the settings UI (#23845)
This PR does some somewhat light UI adjustment to the Assistant 2
settings view. The Prompt Library section should feature the default
prompts in the future, so that's why it's been separated that way.

<img width="800" alt="Screenshot 2025-01-29 at 2 59 59 PM"
src="https://github.com/user-attachments/assets/7b033bde-51ab-44d5-9e53-3f72b8ff5f51"
/>

Release Notes:

- N/A
2025-01-29 16:20:09 -03:00
邻二氮杂菲
29bfb56739
Add DeepSeek support (#23551)
- Added support for DeepSeek as a new language model provider in Zed
Assistant
- Implemented streaming API support for real-time responses from
DeepSeek models.
- Added a configuration UI for DeepSeek API key management and settings.
- Updated documentation with detailed setup instructions for DeepSeek
integration.
- Added DeepSeek-specific icons and model definitions for seamless
integration into the Zed UI.
- Integrated DeepSeek into the language model registry, making it
available alongside other providers like OpenAI and Anthropic.

Release Notes:

- Added support for DeepSeek to the Assistant.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-01-27 13:40:59 -05:00
Mikayla Maki
9cae96f82f
Remove more references to 'model' in GPUI APIs (#23693)
Release Notes:

- N/A
2025-01-27 04:00:27 +00:00
Mikayla Maki
a6b1514246
Fix missed renames in #22632 (#23688)
Fix a bug where a GPUI macro still used `ModelContext`
Rename `AsyncAppContext` -> `AsyncApp`
Rename update_model, read_model, insert_model, and reserve_model to
update_entity, read_entity, insert_entity, and reserve_entity

Release Notes:

- N/A
2025-01-26 23:37:34 +00:00
Nathan Sobo
6fca1d2b0b
Eliminate GPUI View, ViewContext, and WindowContext types (#22632)
There's still a bit more work to do on this, but this PR is compiling
(with warnings) after eliminating the key types. When the tasks below
are complete, this will be the new narrative for GPUI:

- `Entity<T>` - This replaces `View<T>`/`Model<T>`. It represents a unit
of state, and if `T` implements `Render`, then `Entity<T>` implements
`Element`.
- `&mut App` This replaces `AppContext` and represents the app.
- `&mut Context<T>` This replaces `ModelContext` and derefs to `App`. It
is provided by the framework when updating an entity.
- `&mut Window` Broken out of `&mut WindowContext` which no longer
exists. Every method that once took `&mut WindowContext` now takes `&mut
Window, &mut App` and every method that took `&mut ViewContext<T>` now
takes `&mut Window, &mut Context<T>`

Not pictured here are the two other failed attempts. It's been quite a
month!

Tasks:

- [x] Remove `View`, `ViewContext`, `WindowContext` and thread through
`Window`
- [x] [@cole-miller @mikayla-maki] Redraw window when entities change
- [x] [@cole-miller @mikayla-maki] Get examples and Zed running
- [x] [@cole-miller @mikayla-maki] Fix Zed rendering
- [x] [@mikayla-maki] Fix todo! macros and comments
- [x] Fix a bug where the editor would not be redrawn because of view
caching
- [x] remove publicness window.notify() and replace with
`AppContext::notify`
- [x] remove `observe_new_window_models`, replace with
`observe_new_models` with an optional window
- [x] Fix a bug where the project panel would not be redrawn because of
the wrong refresh() call being used
- [x] Fix the tests
- [x] Fix warnings by eliminating `Window` params or using `_`
- [x] Fix conflicts
- [x] Simplify generic code where possible
- [x] Rename types
- [ ] Update docs

### issues post merge

- [x] Issues switching between normal and insert mode
- [x] Assistant re-rendering failure
- [x] Vim test failures
- [x] Mac build issue



Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
Co-authored-by: max <max@zed.dev>
Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Mikayla Maki <mikaylamaki@Mikaylas-MacBook-Pro.local>
Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
Co-authored-by: joão <joao@zed.dev>
2025-01-26 03:02:45 +00:00