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
7d500692
Unverified
Commit
7d500692
authored
Jul 06, 2023
by
Michael Yang
Committed by
GitHub
Jul 06, 2023
Browse files
Merge pull request #50 from jmorganca/go-prompts
fix prompt templates
parents
963c2025
15c114de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
server/routes.go
server/routes.go
+4
-2
No files found.
server/routes.go
View file @
7d500692
...
...
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"log"
"math"
"net"
"net/http"
"path"
...
...
@@ -48,7 +49,7 @@ func generate(c *gin.Context) {
templateNames
=
append
(
templateNames
,
template
.
Name
())
}
match
,
_
:=
matchRankOne
(
path
.
Base
(
req
.
Prompt
),
templateNames
)
match
,
_
:=
matchRankOne
(
path
.
Base
(
req
.
Model
),
templateNames
)
if
template
:=
templates
.
Lookup
(
match
);
template
!=
nil
{
var
sb
strings
.
Builder
if
err
:=
template
.
Execute
(
&
sb
,
req
);
err
!=
nil
{
...
...
@@ -146,8 +147,9 @@ func Serve(ln net.Listener) error {
}
func
matchRankOne
(
source
string
,
targets
[]
string
)
(
bestMatch
string
,
bestRank
int
)
{
bestRank
=
math
.
MaxInt
for
_
,
target
:=
range
targets
{
if
rank
:=
fuzzy
.
LevenshteinDistance
(
source
,
target
);
bestRank
<
rank
{
if
rank
:=
fuzzy
.
LevenshteinDistance
(
source
,
target
);
bestRank
>
rank
{
bestRank
=
rank
bestMatch
=
target
}
...
...
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