Add Ratelimit config (#32)

Signed-off-by: José Ulises Niño Rivera <junr03@users.noreply.github.com>
This commit is contained in:
José Ulises Niño Rivera 2024-08-07 14:15:26 -07:00 committed by GitHub
parent 445b1ea210
commit 2a4cde950d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,32 @@ pub struct Configuration {
pub llm_providers: Vec<LlmProvider>,
pub system_prompt: Option<String>,
pub prompt_targets: Vec<PromptTarget>,
pub ratelimits: Option<Vec<Ratelimit>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ratelimit {
provider: String,
selectors: Vec<Header>,
limit: Limit,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Limit {
tokens: u32,
unit: TimeUnit,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TimeUnit {
#[serde(rename = "minute")]
Minute,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Header {
key: String,
value: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -79,7 +105,6 @@ embedding_provider:
model: "all-MiniLM-L6-v2"
llm_providers:
- name: "open-ai-gpt-4"
api_key: "$OPEN_AI_API_KEY"
model: gpt-4
@ -90,7 +115,6 @@ system_prompt: |
- Use miles per hour for wind speed
prompt_targets:
- type: context_resolver
name: weather_forecast
few_shot_examples:
@ -112,6 +136,14 @@ prompt_targets:
path: /weather
entities:
- name: city
ratelimits:
- provider: open-ai-gpt-4
selectors:
- key: x-katanemo-openai-limit-id
limit:
tokens: 100
unit: minute
"#;
#[test]