Before

…lines 1–287 unchanged (287 lines)
288 // TODO(mxyng): merge this with the glob above
289 js, err = glob(filepath.Join(path, "**/*.json"), "text/plain")
290 if err != nil {
291 return nil, err
292 }
293 files = append(files, js...)
294
295 if tks, _ := glob(filepath.Join(path, "tokenizer.model"), "application/octet-stream"); len(tks) > 0 {
296 // add tokenizer.model if it exists, tokenizer.json is automatically picked up by the previous glob
297 // tokenizer.model might be a unresolved git lfs reference; error if it is
298 files = append(files, tks...)
299 } else if tks, _ := glob(filepath.Join(path, "**/tokenizer.model"), "text/plain"); len(tks) > 0 {
300 // some times tokenizer.model is in a subdirectory (e.g. meta-llama/Meta-Llama-3-8B)
301 files = append(files, tks...)
302 }
303
304 return files, nil
305}
306
307type Command struct {
308 Name string
…lines 309–650 unchanged (342 lines)

After

…lines 1–288 unchanged (288 lines)
289 js, err = glob(filepath.Join(path, "**/*.json"), "text/plain")
290 if err != nil {
291 return nil, err
292 }
293 files = append(files, js...)
294
295 // only include tokenizer.model is tokenizer.json is not present
296 if !slices.ContainsFunc(files, func(s string) bool {
297 return slices.Contains(strings.Split(s, string(os.PathSeparator)), "tokenizer.json")
298 }) {
299 if tks, _ := glob(filepath.Join(path, "tokenizer.model"), "application/octet-stream"); len(tks) > 0 {
300 // add tokenizer.model if it exists, tokenizer.json is automatically picked up by the previous glob
301 // tokenizer.model might be a unresolved git lfs reference; error if it is
302 files = append(files, tks...)
303 } else if tks, _ := glob(filepath.Join(path, "**/tokenizer.model"), "text/plain"); len(tks) > 0 {
304 // some times tokenizer.model is in a subdirectory (e.g. meta-llama/Meta-Llama-3-8B)
305 files = append(files, tks...)
306 }
307 }
308
309 return files, nil
310}
311
312type Command struct {
313 Name string
…lines 314–655 unchanged (342 lines)

Before

source_file
package_clause
package "package"
package_identifier "parser"
import_declaration (+100 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "ErrModelNotFound"
= "="
expression_list
call_expression
selector_expression
identifier "errors"
. "."
field_identifier "New"
argument_list
( "("
interpreted_string_literal
" "\""
interpreted_string_literal_content "no Modelfile or safetensors files found"
" "\""
) ")"
type_declaration
type "type"
type_spec
type_identifier "Modelfile"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "Commands"
slice_type
[ "["
] "]"
type_identifier "Command"
} "}"
method_declaration (+74 nodes collapsed)
var_declaration (+68 nodes collapsed)
comment "// CreateRequest creates a new *api.CreateRequest from an ex"...
method_declaration (+786 nodes collapsed)
function_declaration (+447 nodes collapsed)
function_declaration (+176 nodes collapsed)
function_declaration
func "func"
identifier "filesForModel"
parameter_list
( "("
parameter_declaration
identifier "path"
type_identifier "string"
) ")"
parameter_list
( "("
parameter_declaration
slice_type
[ "["
] "]"
type_identifier "string"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
short_var_declaration (+190 nodes collapsed)
short_var_declaration (+144 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "files"
slice_type
[ "["
] "]"
type_identifier "string"
if_statement (+333 nodes collapsed)
comment "// add configuration files, json files are detected as text/"...
short_var_declaration (+31 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
assignment_statement
expression_list
identifier "files"
= "="
expression_list
call_expression
identifier "append"
argument_list
( "("
identifier "files"
, ","
variadic_argument
identifier "js"
... "..."
) ")"
comment "// bert models require a nested config.json"
comment "// TODO(mxyng): merge this with the glob above"
assignment_statement (+31 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
assignment_statement
expression_list
identifier "files"
= "="
expression_list
call_expression
identifier "append"
argument_list
( "("
identifier "files"
, ","
variadic_argument
identifier "js"
... "..."
) ")"
if_statement (+128 nodes collapsed)
return_statement
return "return"
expression_list
identifier "files"
, ","
nil "nil"
} "}"
type_declaration
type "type"
type_spec
type_identifier "Command"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "Name"
type_identifier "string"
field_declaration
field_identifier "Args"
type_identifier "string"
} "}"
method_declaration (+236 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "state"
type_identifier "int"
const_declaration
const "const"
( "("
const_spec
identifier "stateNil"
type_identifier "state"
= "="
expression_list
iota "iota"
const_spec
identifier "stateName"
const_spec
identifier "stateValue"
const_spec
identifier "stateParameter"
const_spec
identifier "stateMessage"
const_spec
identifier "stateComment"
) ")"
var_declaration (+91 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "ParserError"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "LineNumber"
type_identifier "int"
field_declaration
field_identifier "Msg"
type_identifier "string"
} "}"
method_declaration (+64 nodes collapsed)
function_declaration (+964 nodes collapsed)
function_declaration (+419 nodes collapsed)
function_declaration (+122 nodes collapsed)
function_declaration (+208 nodes collapsed)
function_declaration (+39 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+42 nodes collapsed)
function_declaration (+78 nodes collapsed)
function_declaration (+441 nodes collapsed)
function_declaration (+44 nodes collapsed)

After

source_file
package_clause
package "package"
package_identifier "parser"
import_declaration (+100 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "ErrModelNotFound"
= "="
expression_list
call_expression
selector_expression
identifier "errors"
. "."
field_identifier "New"
argument_list
( "("
interpreted_string_literal
" "\""
interpreted_string_literal_content "no Modelfile or safetensors files found"
" "\""
) ")"
type_declaration
type "type"
type_spec
type_identifier "Modelfile"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "Commands"
slice_type
[ "["
] "]"
type_identifier "Command"
} "}"
method_declaration (+74 nodes collapsed)
var_declaration (+68 nodes collapsed)
comment "// CreateRequest creates a new *api.CreateRequest from an ex"...
method_declaration (+786 nodes collapsed)
function_declaration (+447 nodes collapsed)
function_declaration (+176 nodes collapsed)
function_declaration
func "func"
identifier "filesForModel"
parameter_list
( "("
parameter_declaration
identifier "path"
type_identifier "string"
) ")"
parameter_list
( "("
parameter_declaration
slice_type
[ "["
] "]"
type_identifier "string"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
short_var_declaration (+190 nodes collapsed)
short_var_declaration (+144 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "files"
slice_type
[ "["
] "]"
type_identifier "string"
if_statement (+333 nodes collapsed)
comment "// add configuration files, json files are detected as text/"...
short_var_declaration (+31 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
assignment_statement
expression_list
identifier "files"
= "="
expression_list
call_expression
identifier "append"
argument_list
( "("
identifier "files"
, ","
variadic_argument
identifier "js"
... "..."
) ")"
comment "// bert models require a nested config.json"
comment "// TODO(mxyng): merge this with the glob above"
assignment_statement (+31 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
assignment_statement
expression_list
identifier "files"
= "="
expression_list
call_expression
identifier "append"
argument_list
( "("
identifier "files"
, ","
variadic_argument
identifier "js"
... "..."
) ")"
comment "// only include tokenizer.model is tokenizer.json is not pre"...
if_statement
if "if"
unary_expression
! "!"
call_expression
selector_expression
identifier "slices"
. "."
field_identifier "ContainsFunc"
argument_list
( "("
identifier "files"
, ","
func_literal
func "func"
parameter_list
( "("
parameter_declaration
identifier "s"
type_identifier "string"
) ")"
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
selector_expression
identifier "slices"
. "."
field_identifier "Contains"
argument_list
( "("
call_expression
selector_expression
identifier "strings"
. "."
field_identifier "Split"
argument_list
( "("
identifier "s"
, ","
call_expression
identifier "string"
argument_list
( "("
selector_expression
identifier "os"
. "."
field_identifier "PathSeparator"
) ")"
) ")"
, ","
interpreted_string_literal
" "\""
interpreted_string_literal_content "tokenizer.json"
" "\""
) ")"
} "}"
) ")"
block
{ "{"
statement_list
if_statement (+128 nodes collapsed)
} "}"
return_statement
return "return"
expression_list
identifier "files"
, ","
nil "nil"
} "}"
type_declaration
type "type"
type_spec
type_identifier "Command"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "Name"
type_identifier "string"
field_declaration
field_identifier "Args"
type_identifier "string"
} "}"
method_declaration (+236 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "state"
type_identifier "int"
const_declaration
const "const"
( "("
const_spec
identifier "stateNil"
type_identifier "state"
= "="
expression_list
iota "iota"
const_spec
identifier "stateName"
const_spec
identifier "stateValue"
const_spec
identifier "stateParameter"
const_spec
identifier "stateMessage"
const_spec
identifier "stateComment"
) ")"
var_declaration (+91 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "ParserError"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "LineNumber"
type_identifier "int"
field_declaration
field_identifier "Msg"
type_identifier "string"
} "}"
method_declaration (+64 nodes collapsed)
function_declaration (+964 nodes collapsed)
function_declaration (+419 nodes collapsed)
function_declaration (+122 nodes collapsed)
function_declaration (+208 nodes collapsed)
function_declaration (+39 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+27 nodes collapsed)
function_declaration (+42 nodes collapsed)
function_declaration (+78 nodes collapsed)
function_declaration (+441 nodes collapsed)
function_declaration (+44 nodes collapsed)