File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ macro_rules! starts_with_any {
32
32
///
33
33
/// This function does not panic. It returns a default value of 4096 if the model is not recognized.
34
34
pub fn get_context_size ( model : & str ) -> usize {
35
+ if let Some ( rest) = model. strip_prefix ( "ft:" ) {
36
+ let base = rest. split ( ':' ) . next ( ) . unwrap_or ( rest) ;
37
+ return get_context_size ( base) ;
38
+ }
35
39
if starts_with_any ! ( model, "o1-" ) {
36
40
return 128_000 ;
37
41
}
Original file line number Diff line number Diff line change
1
+ use tiktoken_rs:: model:: get_context_size;
2
+
3
+ #[ test]
4
+ fn test_finetuned_context_size ( ) {
5
+ assert_eq ! (
6
+ get_context_size( "ft:gpt-3.5-turbo-0125:custom" ) ,
7
+ get_context_size( "gpt-3.5-turbo-0125" )
8
+ ) ;
9
+ assert_eq ! (
10
+ get_context_size( "ft:gpt-4o:custom" ) ,
11
+ get_context_size( "gpt-4o" )
12
+ ) ;
13
+ }
You can’t perform that action at this time.
0 commit comments