Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
657685e8
Commit
657685e8
authored
Feb 28, 2025
by
Michael Yang
Browse files
fix: replace deprecated functions
parent
a1491285
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
llama/llama.go
llama/llama.go
+7
-7
No files found.
llama/llama.go
View file @
657685e8
...
@@ -262,7 +262,7 @@ func LoadModelFromFile(modelPath string, params ModelParams) (*Model, error) {
...
@@ -262,7 +262,7 @@ func LoadModelFromFile(modelPath string, params ModelParams) (*Model, error) {
cparams
.
progress_callback_user_data
=
unsafe
.
Pointer
(
&
handle
)
cparams
.
progress_callback_user_data
=
unsafe
.
Pointer
(
&
handle
)
}
}
m
:=
Model
{
c
:
C
.
llama_
load_
model_from_file
(
C
.
CString
(
modelPath
),
cparams
)}
m
:=
Model
{
c
:
C
.
llama_model
_load
_from_file
(
C
.
CString
(
modelPath
),
cparams
)}
if
m
.
c
==
nil
{
if
m
.
c
==
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to load model: %s"
,
modelPath
)
return
nil
,
fmt
.
Errorf
(
"unable to load model: %s"
,
modelPath
)
}
}
...
@@ -271,12 +271,12 @@ func LoadModelFromFile(modelPath string, params ModelParams) (*Model, error) {
...
@@ -271,12 +271,12 @@ func LoadModelFromFile(modelPath string, params ModelParams) (*Model, error) {
}
}
func
FreeModel
(
model
*
Model
)
{
func
FreeModel
(
model
*
Model
)
{
C
.
llama_
free_
model
(
model
.
c
)
C
.
llama_model
_free
(
model
.
c
)
}
}
func
NewContextWithModel
(
model
*
Model
,
params
ContextParams
)
(
*
Context
,
error
)
{
func
NewContextWithModel
(
model
*
Model
,
params
ContextParams
)
(
*
Context
,
error
)
{
c
:=
Context
{
c
:=
Context
{
c
:
C
.
llama_
new_context_with
_model
(
model
.
c
,
params
.
c
),
c
:
C
.
llama_
init_from
_model
(
model
.
c
,
params
.
c
),
numThreads
:
int
(
params
.
c
.
n_threads
),
numThreads
:
int
(
params
.
c
.
n_threads
),
}
}
if
c
.
c
==
nil
{
if
c
.
c
==
nil
{
...
@@ -287,15 +287,15 @@ func NewContextWithModel(model *Model, params ContextParams) (*Context, error) {
...
@@ -287,15 +287,15 @@ func NewContextWithModel(model *Model, params ContextParams) (*Context, error) {
}
}
func
(
m
*
Model
)
NumVocab
()
int
{
func
(
m
*
Model
)
NumVocab
()
int
{
return
int
(
C
.
llama_
n_
vocab
(
m
.
Vocab
()))
return
int
(
C
.
llama_vocab
_n_tokens
(
m
.
Vocab
()))
}
}
func
(
m
*
Model
)
TokenIsEog
(
token
int
)
bool
{
func
(
m
*
Model
)
TokenIsEog
(
token
int
)
bool
{
return
bool
(
C
.
llama_
token
_is_eog
(
m
.
Vocab
(),
C
.
llama_token
(
token
)))
return
bool
(
C
.
llama_
vocab
_is_eog
(
m
.
Vocab
(),
C
.
llama_token
(
token
)))
}
}
func
(
m
*
Model
)
AddBOSToken
()
bool
{
func
(
m
*
Model
)
AddBOSToken
()
bool
{
return
bool
(
C
.
llama_add_bos
_token
(
m
.
Vocab
()))
return
bool
(
C
.
llama_
vocab_get_
add_bos
(
m
.
Vocab
()))
}
}
func
(
m
*
Model
)
ApplyLoraFromFile
(
context
*
Context
,
loraPath
string
,
scale
float32
,
threads
int
)
error
{
func
(
m
*
Model
)
ApplyLoraFromFile
(
context
*
Context
,
loraPath
string
,
scale
float32
,
threads
int
)
error
{
...
@@ -478,7 +478,7 @@ func (m *Model) Tokenize(text string, addSpecial bool, parseSpecial bool) ([]int
...
@@ -478,7 +478,7 @@ func (m *Model) Tokenize(text string, addSpecial bool, parseSpecial bool) ([]int
}
}
func
(
m
*
Model
)
NEmbd
()
int
{
func
(
m
*
Model
)
NEmbd
()
int
{
return
int
(
C
.
llama_n_embd
(
m
.
c
))
return
int
(
C
.
llama_
model_
n_embd
(
m
.
c
))
}
}
func
Quantize
(
infile
,
outfile
string
,
ftype
uint32
)
error
{
func
Quantize
(
infile
,
outfile
string
,
ftype
uint32
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment