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
b36b0b71
Commit
b36b0b71
authored
Oct 16, 2023
by
Michael Yang
Browse files
use cut prefix
parent
094df375
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
llm/llama.go
llm/llama.go
+4
-6
No files found.
llm/llama.go
View file @
b36b0b71
...
@@ -531,16 +531,14 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
...
@@ -531,16 +531,14 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
// This handles the request cancellation
// This handles the request cancellation
return
ctx
.
Err
()
return
ctx
.
Err
()
default
:
default
:
line
:=
scanner
.
Text
()
line
:=
scanner
.
Bytes
()
if
line
==
""
{
if
len
(
line
)
==
0
{
continue
continue
}
}
// Read data from the server-side event stream
if
evt
,
ok
:=
bytes
.
CutPrefix
(
line
,
[]
byte
(
"data: "
));
ok
{
if
strings
.
HasPrefix
(
line
,
"data: "
)
{
evt
:=
line
[
6
:
]
var
p
prediction
var
p
prediction
if
err
:=
json
.
Unmarshal
(
[]
byte
(
evt
)
,
&
p
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
evt
,
&
p
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error unmarshaling llm prediction response: %v"
,
err
)
return
fmt
.
Errorf
(
"error unmarshaling llm prediction response: %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