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

@ -127,6 +127,16 @@ spec:
secretKeyRef:
name: google-ai
key: api_key
- name: QWEN2_7B_API_KEY
valueFrom:
secretKeyRef:
name: hugging-face
key: api_key
- name: QWEN2_7B_API_URL
valueFrom:
secretKeyRef:
name: hugging-face
key: qwen2_api_url
- name: BLOB_STORE_ACCESS_KEY
valueFrom:
secretKeyRef:

View file

@ -151,6 +151,8 @@ pub struct Config {
pub openai_api_key: Option<Arc<str>>,
pub google_ai_api_key: Option<Arc<str>>,
pub anthropic_api_key: Option<Arc<str>>,
pub qwen2_7b_api_key: Option<Arc<str>>,
pub qwen2_7b_api_url: Option<Arc<str>>,
pub zed_client_checksum_seed: Option<String>,
pub slack_panics_webhook: Option<String>,
pub auto_join_channel_id: Option<ChannelId>,

View file

@ -4706,6 +4706,30 @@ async fn stream_complete_with_language_model(
})?;
}
}
Some(proto::LanguageModelProvider::Zed) => {
let api_key = config
.qwen2_7b_api_key
.as_ref()
.context("no Qwen2-7B API key configured on the server")?;
let api_url = config
.qwen2_7b_api_url
.as_ref()
.context("no Qwen2-7B URL configured on the server")?;
let mut events = open_ai::stream_completion(
session.http_client.as_ref(),
&api_url,
api_key,
serde_json::from_str(&request.request)?,
None,
)
.await?;
while let Some(event) = events.next().await {
let event = event?;
response.send(proto::StreamCompleteWithLanguageModelResponse {
event: serde_json::to_string(&event)?,
})?;
}
}
None => return Err(anyhow!("unknown provider"))?,
}

View file

@ -672,6 +672,8 @@ impl TestServer {
stripe_api_key: None,
stripe_price_id: None,
supermaven_admin_api_key: None,
qwen2_7b_api_key: None,
qwen2_7b_api_url: None,
},
})
}