feat(cover): request chatgpt to fill out template

This commit is contained in:
Leons Aleksandrovs
2025-07-12 14:57:59 +03:00
parent b88b0cf7da
commit ea5a2f7fd0
3 changed files with 99 additions and 12 deletions
+14 -2
View File
@@ -3,6 +3,7 @@ package cover
import (
"backend/models/template"
"backend/utils"
"backend/utils/chatgpt"
"backend/utils/jwt"
res "backend/utils/responses"
"net/http"
@@ -43,9 +44,20 @@ func Post(c *gin.Context) {
return
}
// Call chat and ask for cover letter nicely
// Check if template exists
if len(templates) == 0 {
res.Error(c, "Template not found", http.StatusNotFound)
return
}
res.Success(c, templates)
// Call chat and ask for cover letter nicely
coverLetter, err := chatgpt.GenerateCoverLetter(templates[0].Template, data.Application)
if err != nil {
res.Error(c, err.Error(), http.StatusInternalServerError)
return
}
res.Success(c, coverLetter)
}
func Put(c *gin.Context) {