Add Qwen2-7B to the list of zed.dev models (#15649)

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-08-01 22:26:07 +02:00 committed by GitHub
parent 60127f2a8d
commit 21816d1ff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 112 additions and 2 deletions

View file

@ -116,6 +116,8 @@ pub struct Request {
pub model: String,
pub messages: Vec<RequestMessage>,
pub stream: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_tokens: Option<usize>,
pub stop: Vec<String>,
pub temperature: f32,
#[serde(default, skip_serializing_if = "Option::is_none")]
@ -216,6 +218,13 @@ pub struct ChoiceDelta {
pub finish_reason: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum ResponseStreamResult {
Ok(ResponseStreamEvent),
Err { error: String },
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseStreamEvent {
pub created: u32,
@ -256,7 +265,10 @@ pub async fn stream_completion(
None
} else {
match serde_json::from_str(line) {
Ok(response) => Some(Ok(response)),
Ok(ResponseStreamResult::Ok(response)) => Some(Ok(response)),
Ok(ResponseStreamResult::Err { error }) => {
Some(Err(anyhow!(error)))
}
Err(error) => Some(Err(anyhow!(error))),
}
}