File size: 2,538 Bytes
80ffd2e
 
644c352
 
 
 
 
80ffd2e
644c352
 
80ffd2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644c352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80ffd2e
 
 
 
644c352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package types

import (
	"errors"
	"strings"
)

const (
	MorphAPIURL = "https://www.morphllm.com/api/warpgrep-chat"
	LogDir      = "./logs"
)

var MorphHeaders = map[string]string{
	"accept":             "*/*",
	"accept-language":    "zh-CN,zh;q=0.9",
	"cache-control":      "no-cache",
	"content-type":       "application/json",
	"origin":             "https://www.morphllm.com",
	"pragma":             "no-cache",
	"priority":           "u=1, i",
	"referer":            "https://www.morphllm.com/playground/na/warpgrep?repo=tiangolo%2Ffastapi",
	"sec-ch-ua":          `"Not(A:Brand";v="8", "Chromium";v="144", "Google Chrome";v="144"`,
	"sec-ch-ua-mobile":   "?0",
	"sec-ch-ua-platform": `"macOS"`,
	"sec-fetch-dest":     "empty",
	"sec-fetch-mode":     "cors",
	"sec-fetch-site":     "same-origin",
	"user-agent":         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
}

var DebugMode = true

// CookieRotatorInstance is a global reference to the cookie rotator service
// It's set in main.go after initialization
var CookieRotatorInstance interface {
	NextCookie() (cookie interface{}, err error)
	MarkUsed(cookieID uint) error
	MarkError(cookieID uint) error
}

// GetNextCookieFromRotator 从轮询器获取下一个 Cookie
// 这是一个辅助函数,用于从全局轮询器实例获取 Cookie
func GetNextCookieFromRotator() (interface{}, error) {
	if CookieRotatorInstance == nil {
		return nil, errors.New("cookie rotator not initialized")
	}
	return CookieRotatorInstance.NextCookie()
}

type ParsedToolCall struct {
	Name  string                 `json:"name"`
	Input map[string]interface{} `json:"input"`
}

// ========== 模型配置 ==========

// DefaultModel 默认使用的模型
const DefaultModel = "claude-opus-4-5-20251101"

// SupportedModels 支持的模型列表
var SupportedModels = []string{
	"claude-opus-4-5-20251101",
}

// IsModelSupported 检查模型是否在支持列表中
func IsModelSupported(model string) bool {
	if model == "" {
		return false
	}
	for _, supported := range SupportedModels {
		if strings.EqualFold(supported, model) {
			return true
		}
	}
	return false
}

// ========== 认证请求/响应类型 ==========

// ChangePasswordRequest 修改密码请求
type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" binding:"required"`
	NewPassword string `json:"new_password" binding:"required,min=6"`
}