refactor: 将recognizer模块拆分到现有模块中

- 将课表识别功能合并到captcha模块
- 将RecognizerClient添加到client模块
- 将输出函数移至models/output.go
- 更新API结构体添加扩展字段
- 删除recognizer目录
This commit is contained in:
lafay
2026-03-16 13:15:56 +08:00
parent 01ea9ac77d
commit 294151cd40
6 changed files with 287 additions and 323 deletions

View File

@@ -2,9 +2,11 @@ package models
// APIRequest API请求结构
type APIRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
EnableThinking *bool `json:"enable_thinking,omitempty"`
ThinkingBudget *int `json:"thinking_budget,omitempty"`
}
// Message 消息结构

39
models/output.go Normal file
View File

@@ -0,0 +1,39 @@
package models
import (
"encoding/json"
"fmt"
"os"
)
func SaveToJSON(courses []Course, filename string) error {
jsonData, err := json.MarshalIndent(courses, "", " ")
if err != nil {
return err
}
err = os.WriteFile(filename, jsonData, 0644)
if err != nil {
return err
}
fmt.Printf("[输出] JSON结果已保存到: %s\n", filename)
return nil
}
func PrintCourses(courses []Course) {
fmt.Println("\n==================================================")
fmt.Println("识别结果:")
fmt.Println("==================================================")
for i, course := range courses {
fmt.Printf("\n课程 %d: %s\n", i+1, course.Name)
fmt.Printf(" 教师: %s\n", course.Teacher)
fmt.Printf(" 教室: %s\n", course.Room)
fmt.Printf(" 时间:")
for _, sch := range course.Schedule {
fmt.Printf(" %s %v 周%v", sch.Day, sch.Section, sch.Weeks)
}
fmt.Println()
}
fmt.Println("\n==================================================")
}