ZIm/crates/rpc/src/llm.rs
Marshall Bowers 30056254f3
collab: Add GET /models endpoint to LLM service (#17307)
This PR adds a `GET /models` endpoint to the LLM service.

This endpoint returns the models that the authenticated user has access
to.

This is the first step towards populating the models for the hosted
service from the server.

Release Notes:

- N/A
2024-09-03 11:41:32 -04:00

34 lines
876 B
Rust

use serde::{Deserialize, Serialize};
use strum::{Display, EnumIter, EnumString};
pub const EXPIRED_LLM_TOKEN_HEADER_NAME: &str = "x-zed-expired-token";
#[derive(
Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, EnumString, EnumIter, Display,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum LanguageModelProvider {
Anthropic,
OpenAi,
Google,
Zed,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LanguageModel {
pub provider: LanguageModelProvider,
pub name: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ListModelsResponse {
pub models: Vec<LanguageModel>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PerformCompletionParams {
pub provider: LanguageModelProvider,
pub model: String,
pub provider_request: Box<serde_json::value::RawValue>,
}