fix askai route
This commit is contained in:
parent
5af0014481
commit
92f4e9e919
@ -30,27 +30,36 @@ func registerAskAIRoutes(r *gin.RouterGroup) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var chunks any
|
||||
if ragSvc != nil {
|
||||
docs, _ := ragSvc.Query(c.Request.Context(), req.Question, 5)
|
||||
chunks = docs
|
||||
}
|
||||
|
||||
answer, err := askFn(req.Question)
|
||||
if err != nil {
|
||||
provider, _, _, _, timeout, retries := loadConfig()
|
||||
slog.Error("askai request failed",
|
||||
"question", req.Question,
|
||||
"provider", provider,
|
||||
"err", err,
|
||||
)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
"config": gin.H{
|
||||
"timeout": timeout.Seconds(),
|
||||
"retries": retries,
|
||||
},
|
||||
})
|
||||
return
|
||||
if err != nil {
|
||||
provider, _, _, _, timeout, retries := loadConfig()
|
||||
slog.Error("askai request failed",
|
||||
"question", req.Question,
|
||||
"provider", provider,
|
||||
"err", err,
|
||||
)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
"config": gin.H{
|
||||
"timeout": timeout.Seconds(),
|
||||
"retries": retries,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"answer": answer,
|
||||
"chunks": chunks,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ConfigPath points to the server configuration file.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user