Skip to content

Commit

Permalink
chore(ai-help): stop generating off-topic answer (#455)
Browse files Browse the repository at this point in the history
* chore(ai-help): stop generating off-topic answer

* use unwrap_or_default

---------

Co-authored-by: Florian Dieminger <[email protected]>
  • Loading branch information
caugner and fiji-flo authored Mar 27, 2024
1 parent d035afa commit 7dc8a6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ai/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct AIHelpConfig {
pub full_doc: bool,
pub system_prompt: &'static str,
pub user_prompt: Option<&'static str>,
pub stop_phrase: Option<&'static str>,
pub token_limit: usize,
pub context_limit: usize,
pub max_completion_tokens: usize,
Expand All @@ -29,6 +30,7 @@ pub const AI_HELP_GPT3_5_FULL_DOC_NEW_PROMPT: AIHelpConfig = AIHelpConfig {
full_doc: true,
system_prompt: include_str!("prompts/new_prompt/system.md"),
user_prompt: None,
stop_phrase: Some(include_str!("prompts/new_prompt/stop_phrase.txt")),
token_limit: 16_384,
context_limit: 12_000,
max_completion_tokens: 2_048,
Expand All @@ -41,6 +43,7 @@ pub const AI_HELP_GPT4_FULL_DOC_NEW_PROMPT: AIHelpConfig = AIHelpConfig {
full_doc: true,
system_prompt: include_str!("prompts/new_prompt/system.md"),
user_prompt: None,
stop_phrase: Some(include_str!("prompts/new_prompt/stop_phrase.txt")),
token_limit: 32_768,
context_limit: 20_000,
max_completion_tokens: 4_096,
Expand Down
1 change: 1 addition & 0 deletions src/ai/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub async fn prepare_ai_help_req(
.model(config.model)
.messages(messages)
.temperature(0.0)
.stop(config.stop_phrase.unwrap_or_default())
.build()?;
request_meta.model = Some(config.model);

Expand Down
1 change: 1 addition & 0 deletions src/ai/prompts/new_prompt/stop_phrase.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I'm sorry, but I can't

0 comments on commit 7dc8a6e

Please sign in to comment.