fix: update app key
This commit is contained in:
@@ -18,6 +18,7 @@ func SetupRouter(engine *gin.RouterGroup) {
|
|||||||
formulaRouter.POST("/recognition", endpoint.CreateTask)
|
formulaRouter.POST("/recognition", endpoint.CreateTask)
|
||||||
formulaRouter.POST("/ai_enhance", endpoint.AIEnhanceRecognition)
|
formulaRouter.POST("/ai_enhance", endpoint.AIEnhanceRecognition)
|
||||||
formulaRouter.GET("/recognition/:task_no", endpoint.GetTaskStatus)
|
formulaRouter.GET("/recognition/:task_no", endpoint.GetTaskStatus)
|
||||||
|
formulaRouter.POST("/test_process_mathpix_task", endpoint.TestProcessMathpixTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
taskRouter := v1.Group("/task", common.GetAuthMiddleware())
|
taskRouter := v1.Group("/task", common.GetAuthMiddleware())
|
||||||
|
|||||||
@@ -121,3 +121,20 @@ func (endpoint *FormulaEndpoint) AIEnhanceRecognition(c *gin.Context) {
|
|||||||
|
|
||||||
c.JSON(http.StatusOK, common.SuccessResponse(c, nil))
|
c.JSON(http.StatusOK, common.SuccessResponse(c, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (endpoint *FormulaEndpoint) TestProcessMathpixTask(c *gin.Context) {
|
||||||
|
postData := make(map[string]int)
|
||||||
|
if err := c.BindJSON(&postData); err != nil {
|
||||||
|
c.JSON(http.StatusOK, common.ErrorResponse(c, common.CodeParamError, "Invalid parameters"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
taskID := postData["task_id"]
|
||||||
|
err := endpoint.recognitionService.TestProcessMathpixTask(c, int64(taskID))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, common.ErrorResponse(c, common.CodeSystemError, err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, common.SuccessResponse(c, nil))
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,4 +47,4 @@ aliyun:
|
|||||||
|
|
||||||
mathpix:
|
mathpix:
|
||||||
app_id: "ocr_eede6f_ea9b5c"
|
app_id: "ocr_eede6f_ea9b5c"
|
||||||
app_key: "683f7133391a1039383161653531396234343536393263346632613437343332"
|
app_key: "fb72d251e33ac85c929bfd4eec40d78368d08d82fb2ee1cffb04a8bb967d1db5"
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ type MathpixRequest struct {
|
|||||||
// 高级表格处理,默认false
|
// 高级表格处理,默认false
|
||||||
EnableTablesFallback bool `json:"enable_tables_fallback"`
|
EnableTablesFallback bool `json:"enable_tables_fallback"`
|
||||||
// 全角标点,null表示自动判断
|
// 全角标点,null表示自动判断
|
||||||
FullwidthPunctuation *bool `json:"fullwidth_punctuation"`
|
FullwidthPunctuation *bool `json:"fullwidth_punctuation,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MathpixCallback 回调配置
|
// MathpixCallback 回调配置
|
||||||
@@ -819,3 +819,16 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
|
|||||||
isSuccess = true
|
isSuccess = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RecognitionService) TestProcessMathpixTask(ctx context.Context, taskID int64) error {
|
||||||
|
task, err := dao.NewRecognitionTaskDao().GetTaskByID(dao.DB.WithContext(ctx), taskID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(ctx, "func", "TestProcessMathpixTask", "msg", "获取任务失败", "error", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if task == nil {
|
||||||
|
log.Error(ctx, "func", "TestProcessMathpixTask", "msg", "任务不存在", "task_id", taskID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return s.processMathpixTask(ctx, taskID, task.FileURL)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ type RecognitionResult struct {
|
|||||||
BaseModel
|
BaseModel
|
||||||
TaskID int64 `gorm:"column:task_id;bigint;not null;default:0;comment:任务ID" json:"task_id"`
|
TaskID int64 `gorm:"column:task_id;bigint;not null;default:0;comment:任务ID" json:"task_id"`
|
||||||
TaskType TaskType `gorm:"column:task_type;varchar(16);not null;comment:任务类型;default:''" json:"task_type"`
|
TaskType TaskType `gorm:"column:task_type;varchar(16);not null;comment:任务类型;default:''" json:"task_type"`
|
||||||
Latex string `json:"latex"`
|
Latex string `json:"latex" gorm:"column:latex;type:text;not null;default:''"`
|
||||||
Markdown string `json:"markdown"` // Mathpix Markdown 格式
|
Markdown string `json:"markdown" gorm:"column:markdown;type:text;not null;default:''"` // Mathpix Markdown 格式
|
||||||
MathML string `json:"mathml"` // MathML 格式
|
MathML string `json:"mathml" gorm:"column:mathml;type:text;not null;default:''"` // MathML 格式
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecognitionResultDao struct {
|
type RecognitionResultDao struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user