Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ai-help): stop generating off-topic answer #455

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading