mirror of
https://github.com/ollama/ollama.git
synced 2025-11-12 23:07:26 +01:00
return error in generate response
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
@@ -46,7 +45,7 @@ func generate(c *gin.Context) {
|
||||
req.PredictOptions = &api.DefaultPredictOptions
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,7 +65,7 @@ func generate(c *gin.Context) {
|
||||
|
||||
model, err := llama.New(req.Model, modelOpts)
|
||||
if err != nil {
|
||||
fmt.Println("Loading the model failed:", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
defer model.Free()
|
||||
@@ -80,7 +79,7 @@ func generate(c *gin.Context) {
|
||||
if template := templates.Lookup(match); template != nil {
|
||||
var sb strings.Builder
|
||||
if err := template.Execute(&sb, req); err != nil {
|
||||
fmt.Println("Prompt template failed:", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user