diff --git a/src/ai/constants.rs b/src/ai/constants.rs index 2c39d169..f268eaec 100644 --- a/src/ai/constants.rs +++ b/src/ai/constants.rs @@ -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, @@ -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, @@ -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, diff --git a/src/ai/help.rs b/src/ai/help.rs index ab8c15d7..34b46438 100644 --- a/src/ai/help.rs +++ b/src/ai/help.rs @@ -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); diff --git a/src/ai/prompts/new_prompt/stop_phrase.txt b/src/ai/prompts/new_prompt/stop_phrase.txt new file mode 100644 index 00000000..39592455 --- /dev/null +++ b/src/ai/prompts/new_prompt/stop_phrase.txt @@ -0,0 +1 @@ +I'm sorry, but I can't \ No newline at end of file