mirror of
https://github.com/openai/codex.git
synced 2026-05-02 20:32:04 +03:00
feat(core) ModelInfo.model_instructions_template (#9597)
## Summary #9555 is the start of a rename, so I'm starting to standardize here. Sets up `model_instructions` templating with a strongly-typed object for injecting a personality block into the model instructions. ## Testing - [x] Added tests - [x] Ran locally
This commit is contained in:
@@ -86,8 +86,9 @@ impl ContextManager {
|
||||
// This is a coarse lower bound, not a tokenizer-accurate count.
|
||||
pub(crate) fn estimate_token_count(&self, turn_context: &TurnContext) -> Option<i64> {
|
||||
let model_info = turn_context.client.get_model_info();
|
||||
let base_instructions = model_info.base_instructions.as_str();
|
||||
let base_tokens = i64::try_from(approx_token_count(base_instructions)).unwrap_or(i64::MAX);
|
||||
let personality = turn_context.client.config().model_personality;
|
||||
let base_instructions = model_info.get_model_instructions(personality);
|
||||
let base_tokens = i64::try_from(approx_token_count(&base_instructions)).unwrap_or(i64::MAX);
|
||||
|
||||
let items_tokens = self.items.iter().fold(0i64, |acc, item| {
|
||||
acc + match item {
|
||||
|
||||
Reference in New Issue
Block a user