assistant: Limit model access for Zed AI users to Claude-3.5-sonnet (#15904)

This prevents users from accessing other models, such as OpenAI's GPT-4
or Google's Gemini-Pro.
Staff members can still access all models.

Co-authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Bennet Bo Fenner 2024-08-07 16:26:56 +02:00 committed by GitHub
parent efbf7ada28
commit 3a52d6cc52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 130 additions and 5 deletions

View file

@ -13,13 +13,19 @@ pub struct LlmTokenClaims {
pub exp: u64,
pub jti: String,
pub user_id: u64,
pub is_staff: bool,
pub plan: rpc::proto::Plan,
}
const LLM_TOKEN_LIFETIME: Duration = Duration::from_secs(60 * 60);
impl LlmTokenClaims {
pub fn create(user_id: UserId, plan: rpc::proto::Plan, config: &Config) -> Result<String> {
pub fn create(
user_id: UserId,
is_staff: bool,
plan: rpc::proto::Plan,
config: &Config,
) -> Result<String> {
let secret = config
.llm_api_secret
.as_ref()
@ -31,6 +37,7 @@ impl LlmTokenClaims {
exp: (now + LLM_TOKEN_LIFETIME).timestamp() as u64,
jti: uuid::Uuid::new_v4().to_string(),
user_id: user_id.to_proto(),
is_staff,
plan,
};