added initial placeholder for truncation without a valid strategy
This commit is contained in:
parent
473067db31
commit
32853c2044
2 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use anyhow::anyhow;
|
||||||
use language::ToOffset;
|
use language::ToOffset;
|
||||||
|
|
||||||
use crate::templates::base::PromptArguments;
|
use crate::templates::base::PromptArguments;
|
||||||
|
@ -12,6 +13,12 @@ impl PromptTemplate for FileContext {
|
||||||
args: &PromptArguments,
|
args: &PromptArguments,
|
||||||
max_token_length: Option<usize>,
|
max_token_length: Option<usize>,
|
||||||
) -> anyhow::Result<(String, usize)> {
|
) -> anyhow::Result<(String, usize)> {
|
||||||
|
if max_token_length.is_some() {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"no truncation strategy established for file_context template"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let mut prompt = String::new();
|
let mut prompt = String::new();
|
||||||
|
|
||||||
// Add Initial Preamble
|
// Add Initial Preamble
|
||||||
|
|
|
@ -18,6 +18,12 @@ impl PromptTemplate for GenerateInlineContent {
|
||||||
args: &PromptArguments,
|
args: &PromptArguments,
|
||||||
max_token_length: Option<usize>,
|
max_token_length: Option<usize>,
|
||||||
) -> anyhow::Result<(String, usize)> {
|
) -> anyhow::Result<(String, usize)> {
|
||||||
|
if max_token_length.is_some() {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"no truncation strategy established for generating inline content template"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let Some(user_prompt) = &args.user_prompt else {
|
let Some(user_prompt) = &args.user_prompt else {
|
||||||
return Err(anyhow!("user prompt not provided"));
|
return Err(anyhow!("user prompt not provided"));
|
||||||
};
|
};
|
||||||
|
@ -83,6 +89,7 @@ impl PromptTemplate for GenerateInlineContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let token_count = args.model.count_tokens(&prompt)?;
|
let token_count = args.model.count_tokens(&prompt)?;
|
||||||
|
|
||||||
anyhow::Ok((prompt, token_count))
|
anyhow::Ok((prompt, token_count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue