separate routes
This commit is contained in:
parent
fd962a36e5
commit
8ea5e5e147
1 changed files with 45 additions and 36 deletions
|
@ -14,15 +14,17 @@ import (
|
||||||
"github.com/jmorganca/ollama/api"
|
"github.com/jmorganca/ollama/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Serve(ln net.Listener) error {
|
func pull(c *gin.Context) {
|
||||||
r := gin.Default()
|
// TODO
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "ok"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func generate(c *gin.Context) {
|
||||||
// TODO: these should be request parameters
|
// TODO: these should be request parameters
|
||||||
gpulayers := 0
|
gpulayers := 0
|
||||||
tokens := 512
|
tokens := 512
|
||||||
threads := runtime.NumCPU()
|
threads := runtime.NumCPU()
|
||||||
|
|
||||||
r.POST("/api/generate", func(c *gin.Context) {
|
|
||||||
// TODO: set prompt from template
|
// TODO: set prompt from template
|
||||||
fmt.Println("Generating text...")
|
fmt.Println("Generating text...")
|
||||||
|
|
||||||
|
@ -61,7 +63,14 @@ func Serve(ln net.Listener) error {
|
||||||
c.SSEvent("token", tok)
|
c.SSEvent("token", tok)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
func Serve(ln net.Listener) error {
|
||||||
|
r := gin.Default()
|
||||||
|
|
||||||
|
r.POST("api/pull", pull)
|
||||||
|
|
||||||
|
r.POST("/api/generate", generate)
|
||||||
|
|
||||||
log.Printf("Listening on %s", ln.Addr())
|
log.Printf("Listening on %s", ln.Addr())
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
|
|
Loading…
Reference in a new issue