Skip to content

Commit

Permalink
fix: ChatCompletionRequest.presense_penalty shall be optional (#2211)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys authored May 21, 2024
1 parent 950842b commit 59b70e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/tabby/src/services/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl AnswerService {
// 5. Generate answer from the query
let s = self.chat.clone().generate(ChatCompletionRequestBuilder::default()
.messages(req.messages.clone())
.presence_penalty(PRESENCE_PENALTY)
.presence_penalty(Some(PRESENCE_PENALTY))
.build()
.expect("Failed to create ChatCompletionRequest"))
.await;
Expand Down
8 changes: 5 additions & 3 deletions crates/tabby/src/services/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub struct ChatCompletionRequest {
#[builder(default = "None")]
seed: Option<u64>,

#[builder(default = "0.0")]
presence_penalty: f32,
#[builder(default = "None")]
presence_penalty: Option<f32>,
}

#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
Expand Down Expand Up @@ -106,8 +106,10 @@ impl ChatService {
request.seed.inspect(|x| {
builder.seed(*x);
});
request.presence_penalty.inspect(|x| {
builder.presence_penalty(*x);
});
builder
.presence_penalty(request.presence_penalty)
.build()
.expect("Failed to create ChatCompletionOptions")
};
Expand Down

0 comments on commit 59b70e6

Please sign in to comment.