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
235e43d7
Unverified
Commit
235e43d7
authored
Oct 18, 2023
by
Michael Yang
Committed by
GitHub
Oct 18, 2023
Browse files
Merge pull request #833 from discovertomorrow/leadingspace
Fix Issue with Leading Whitespaces in Decoded Context
parents
627d04d9
730996e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
llm/llama.go
llm/llama.go
+3
-3
No files found.
llm/llama.go
View file @
235e43d7
...
@@ -479,6 +479,9 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
...
@@ -479,6 +479,9 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
return
err
return
err
}
}
// Remove leading spaces from prevConvo if present
prevConvo
=
strings
.
TrimPrefix
(
prevConvo
,
" "
)
var
nextContext
strings
.
Builder
var
nextContext
strings
.
Builder
nextContext
.
WriteString
(
prevConvo
)
nextContext
.
WriteString
(
prevConvo
)
nextContext
.
WriteString
(
prompt
)
nextContext
.
WriteString
(
prompt
)
...
@@ -688,9 +691,6 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) {
...
@@ -688,9 +691,6 @@ func (llm *llama) Decode(ctx context.Context, tokens []int) (string, error) {
return
""
,
fmt
.
Errorf
(
"unmarshal encode response: %w"
,
err
)
return
""
,
fmt
.
Errorf
(
"unmarshal encode response: %w"
,
err
)
}
}
// decoded content contains a leading whitespace
decoded
.
Content
,
_
=
strings
.
CutPrefix
(
decoded
.
Content
,
""
)
return
decoded
.
Content
,
nil
return
decoded
.
Content
,
nil
}
}
...
...
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