Skip to content

Commit

Permalink
feat: add repetition_penalty and top_k to openai (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
huytuong010101 authored Feb 29, 2024
1 parent 6d8d711 commit f915df7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ struct ChatCompletionRequest {
// Additional parameters
// TODO(travis): add other LoRAX params here
response_format: Option<ResponseFormat>,
repetition_penalty: Option<f32>,
top_k: Option<i32>,
}

#[derive(Clone, Debug, Deserialize, ToSchema)]
Expand All @@ -478,6 +480,8 @@ struct CompletionRequest {
user: Option<String>,
// Additional parameters
// TODO(travis): add other LoRAX params here
repetition_penalty: Option<f32>,
top_k: Option<i32>,
}

#[derive(Serialize, ToSchema)]
Expand Down Expand Up @@ -587,8 +591,8 @@ impl From<CompletionRequest> for CompatGenerateRequest {
api_token: None,
best_of: req.best_of.map(|x| x as usize),
temperature: req.temperature,
repetition_penalty: None,
top_k: None,
repetition_penalty: req.repetition_penalty,
top_k: req.top_k,
top_p: req.top_p,
typical_p: None,
do_sample: !req.n.is_none(),
Expand Down Expand Up @@ -622,8 +626,8 @@ impl From<ChatCompletionRequest> for CompatGenerateRequest {
api_token: None,
best_of: req.n.map(|x| x as usize),
temperature: req.temperature,
repetition_penalty: None,
top_k: None,
repetition_penalty: req.repetition_penalty,
top_k: req.top_k,
top_p: req.top_p,
typical_p: None,
do_sample: !req.n.is_none(),
Expand Down

0 comments on commit f915df7

Please sign in to comment.