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
49a54831
"git@developer.sourcefind.cn:OpenDAS/pytorch3d.git" did not exist on "fbd3c679acb6e8ac61c0ca4bc1242a9e665d9ace"
Commit
49a54831
authored
Aug 01, 2024
by
Vyacheslav Moskalev
Browse files
Change the order of context and prompt.
parent
6bc5c137
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
server/routes.go
server/routes.go
+7
-6
No files found.
server/routes.go
View file @
49a54831
...
@@ -188,21 +188,22 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -188,21 +188,22 @@ func (s *Server) GenerateHandler(c *gin.Context) {
}
}
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
if
err
:=
tmpl
.
Execute
(
&
b
,
values
);
err
!=
nil
{
var
t
bytes
.
Buffer
if
err
:=
tmpl
.
Execute
(
&
t
,
values
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
if
req
.
Context
!=
nil
{
if
req
.
Context
!=
nil
{
s
,
err
:=
r
.
Detokenize
(
c
.
Request
.
Context
(),
req
.
Context
)
prev
,
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
(
prev
)
b
.
WriteString
(
s
)
}
}
b
.
WriteString
(
t
.
String
());
prompt
=
b
.
String
()
prompt
=
b
.
String
()
}
}
...
@@ -242,12 +243,12 @@ func (s *Server) GenerateHandler(c *gin.Context) {
...
@@ -242,12 +243,12 @@ func (s *Server) GenerateHandler(c *gin.Context) {
res
.
LoadDuration
=
checkpointLoaded
.
Sub
(
checkpointStart
)
res
.
LoadDuration
=
checkpointLoaded
.
Sub
(
checkpointStart
)
if
!
req
.
Raw
{
if
!
req
.
Raw
{
tokens
,
err
:=
r
.
Tokenize
(
c
.
Request
.
Context
(),
prompt
+
sb
.
String
())
tokens
,
err
:=
r
.
Tokenize
(
c
.
Request
.
Context
(),
prompt
+
sb
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
return
return
}
}
res
.
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