<img width="624" alt="image" src="https://github.com/user-attachments/assets/f492b0bd-14c3-49e2-b2ff-dc78e52b0815"> - [x] Correctly set custom model token count - [x] How to count tokens for Gemini models? - [x] Feature flag zed.dev provider - [x] Figure out how to configure custom models - [ ] Update docs Release Notes: - Added support for quickly switching between multiple language model providers in the assistant panel --------- Co-authored-by: Antonio <antonio@zed.dev>
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
use crate::{role::Role, LanguageModelId};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
|
pub struct LanguageModelRequestMessage {
|
|
pub role: Role,
|
|
pub content: String,
|
|
}
|
|
|
|
impl LanguageModelRequestMessage {
|
|
pub fn to_proto(&self) -> proto::LanguageModelRequestMessage {
|
|
proto::LanguageModelRequestMessage {
|
|
role: self.role.to_proto() as i32,
|
|
content: self.content.clone(),
|
|
tool_calls: Vec::new(),
|
|
tool_call_id: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Default, Serialize, Deserialize)]
|
|
pub struct LanguageModelRequest {
|
|
pub messages: Vec<LanguageModelRequestMessage>,
|
|
pub stop: Vec<String>,
|
|
pub temperature: f32,
|
|
}
|
|
|
|
impl LanguageModelRequest {
|
|
pub fn to_proto(&self, model_id: LanguageModelId) -> proto::CompleteWithLanguageModel {
|
|
proto::CompleteWithLanguageModel {
|
|
model: model_id.0.to_string(),
|
|
messages: self.messages.iter().map(|m| m.to_proto()).collect(),
|
|
stop: self.stop.clone(),
|
|
temperature: self.temperature,
|
|
tool_choice: None,
|
|
tools: Vec::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
|
pub struct LanguageModelResponseMessage {
|
|
pub role: Option<Role>,
|
|
pub content: Option<String>,
|
|
}
|