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
ff7c9060
Unverified
Commit
ff7c9060
authored
Aug 01, 2024
by
Michael Yang
Committed by
GitHub
Aug 01, 2024
Browse files
Merge pull request #6115 from slouffka/fix-context
Fix context in /api/generate grows too much (#5980).
parents
0ff42e84
8a9f946c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
server/routes.go
server/routes.go
+6
-7
No files found.
server/routes.go
View file @
ff7c9060
...
@@ -188,21 +188,20 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -188,21 +188,20 @@ func (s *Server) GenerateHandler(c *gin.Context) {
}
}
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
if
err
:=
tmpl
.
Execute
(
&
b
,
values
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
if
req
.
Context
!=
nil
{
if
req
.
Context
!=
nil
{
s
,
err
:=
r
.
Detokenize
(
c
.
Request
.
Context
(),
req
.
Context
)
s
,
err
:=
r
.
Detokenize
(
c
.
Request
.
Context
(),
req
.
Context
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
b
.
WriteString
(
s
)
b
.
WriteString
(
s
)
}
}
if
err
:=
tmpl
.
Execute
(
&
b
,
values
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
prompt
=
b
.
String
()
prompt
=
b
.
String
()
}
}
...
@@ -247,7 +246,7 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -247,7 +246,7 @@ func (s *Server) GenerateHandler(c *gin.Context) {
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
return
return
}
}
res
.
Context
=
append
(
req
.
Context
,
tokens
...
)
res
.
Context
=
tokens
}
}
}
}
...
...
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