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
f55bdb6f
Unverified
Commit
f55bdb6f
authored
Oct 17, 2023
by
Michael Yang
Committed by
GitHub
Oct 17, 2023
Browse files
Merge pull request #799 from deichbewohner/jsonmarshaling
Fix JSON Marshal Escaping for Special Characters
parents
2870a9bf
8fa3f366
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
llm/llama.go
llm/llama.go
+8
-4
No files found.
llm/llama.go
View file @
f55bdb6f
...
@@ -541,12 +541,16 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
...
@@ -541,12 +541,16 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
Stop
:
llm
.
Stop
,
Stop
:
llm
.
Stop
,
}
}
data
,
err
:=
json
.
Marshal
(
predReq
)
// Handling JSON marshaling with special characters unescaped.
if
err
!=
nil
{
buffer
:=
&
bytes
.
Buffer
{}
return
fmt
.
Errorf
(
"error marshaling data: %v"
,
err
)
enc
:=
json
.
NewEncoder
(
buffer
)
enc
.
SetEscapeHTML
(
false
)
if
err
:=
enc
.
Encode
(
predReq
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to marshal data: %v"
,
err
)
}
}
req
,
err
:=
http
.
NewRequestWithContext
(
ctx
,
http
.
MethodPost
,
endpoint
,
b
ytes
.
NewBuffer
(
data
)
)
req
,
err
:=
http
.
NewRequestWithContext
(
ctx
,
http
.
MethodPost
,
endpoint
,
b
uffer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error creating POST request: %v"
,
err
)
return
fmt
.
Errorf
(
"error creating POST request: %v"
,
err
)
}
}
...
...
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