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
ecf14a22
Unverified
Commit
ecf14a22
authored
May 10, 2025
by
frob
Committed by
GitHub
May 10, 2025
Browse files
llama: allocate grammar buffer based on schema length (#10649)
parent
69ce44b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
llama/llama.go
llama/llama.go
+2
-2
No files found.
llama/llama.go
View file @
ecf14a22
...
@@ -637,8 +637,8 @@ func SchemaToGrammar(schema []byte) []byte {
...
@@ -637,8 +637,8 @@ func SchemaToGrammar(schema []byte) []byte {
cStr
:=
C
.
CString
(
string
(
schema
))
cStr
:=
C
.
CString
(
string
(
schema
))
defer
C
.
free
(
unsafe
.
Pointer
(
cStr
))
defer
C
.
free
(
unsafe
.
Pointer
(
cStr
))
// Allocate buffer for grammar
output with reasonable size
// Allocate buffer for grammar
based on schema length but with upper bound
const
maxLen
=
32768
// 32KB
maxLen
:
=
min
(
1024
*
1024
,
len
(
schema
)
*
4
)
buf
:=
make
([]
byte
,
maxLen
)
buf
:=
make
([]
byte
,
maxLen
)
// Call C function to convert schema to grammar
// Call C function to convert schema to grammar
...
...
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