diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-25 18:47:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-25 18:47:11 +0800 |
| commit | 34a6d13fb6e492860e1340ab7a97cbd1bdeb9d4d (patch) | |
| tree | a3e17b41c71963a7bf89e425c18bd059df296e42 /src/config | |
| parent | aeeca1c010117d7455cdbe2652769ca3fad3bb36 (diff) | |
| download | aichat-34a6d13fb6e492860e1340ab7a97cbd1bdeb9d4d.tar.gz | |
refactor: compress session (#649)
1. no require compress_threshold >= 1000
2. no compressing in middle of function calling
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/session.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/config/session.rs b/src/config/session.rs index 3330f22..3057697 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -110,11 +110,9 @@ impl Session { self.save_session } - pub fn need_compress(&self, current_compress_threshold: usize) -> bool { - let threshold = self - .compress_threshold - .unwrap_or(current_compress_threshold); - threshold >= 1000 && self.tokens() > threshold + pub fn need_compress(&self, global_compress_threshold: usize) -> bool { + let threshold = self.compress_threshold.unwrap_or(global_compress_threshold); + threshold > 0 && self.tokens() > threshold } pub fn tokens(&self) -> usize { |
