mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-03 23:33:37 +08:00
refine cursor pos data structure
This commit is contained in:
@@ -45,13 +45,13 @@ type AcceptCompletionReq struct {
|
||||
}
|
||||
|
||||
type ReportReq struct {
|
||||
Action consts.ReportAction `json:"action"`
|
||||
ID string `json:"id"` // task_id or resp_id
|
||||
Content string `json:"content"` // 内容
|
||||
Tool string `json:"tool"` // 工具
|
||||
UserInput string `json:"user_input"` // 用户输入的新文本(用于reject action)
|
||||
SourceCode string `json:"source_code"` // 当前文件的原文(用于reject action)
|
||||
CursorPosition map[string]interface{} `json:"cursor_position"` // 光标位置(用于reject action)
|
||||
Action consts.ReportAction `json:"action"`
|
||||
ID string `json:"id"` // task_id or resp_id
|
||||
Content string `json:"content"` // 内容
|
||||
Tool string `json:"tool"` // 工具
|
||||
UserInput string `json:"user_input"` // 用户输入的新文本(用于reject action)
|
||||
SourceCode string `json:"source_code"` // 当前文件的原文(用于reject action)
|
||||
CursorPosition map[string]any `json:"cursor_position"` // 光标位置(用于reject action)
|
||||
}
|
||||
|
||||
type RecordParam struct {
|
||||
@@ -70,9 +70,9 @@ type RecordParam struct {
|
||||
WorkMode string
|
||||
CodeLines int64
|
||||
Code string
|
||||
SourceCode string // 当前文件的原文
|
||||
CursorPosition map[string]interface{} // 光标位置
|
||||
UserInput string // 用户实际输入的内容
|
||||
SourceCode string // 当前文件的原文
|
||||
CursorPosition map[string]any // 光标位置
|
||||
UserInput string // 用户实际输入的内容
|
||||
}
|
||||
|
||||
func (r *RecordParam) Clone() *RecordParam {
|
||||
|
||||
@@ -393,26 +393,26 @@ func (s *Setting) From(e *db.Setting) *Setting {
|
||||
|
||||
// CompletionData 补全数据导出结构
|
||||
type CompletionData struct {
|
||||
TaskID string `json:"task_id"` // 任务ID
|
||||
UserID string `json:"user_id"` // 用户ID
|
||||
ModelID string `json:"model_id"` // 模型ID
|
||||
ModelName string `json:"model_name"` // 模型名称
|
||||
RequestID string `json:"request_id"` // 请求ID
|
||||
ModelType string `json:"model_type"` // 模型类型
|
||||
ProgramLanguage string `json:"program_language"` // 编程语言
|
||||
WorkMode string `json:"work_mode"` // 工作模式
|
||||
Prompt string `json:"prompt"` // 用户输入的提示
|
||||
Completion string `json:"completion"` // LLM生成的补全代码
|
||||
SourceCode string `json:"source_code"` // 当前文件原文
|
||||
CursorPosition map[string]interface{} `json:"cursor_position"` // 光标位置 {"line": 10, "column": 5}
|
||||
UserInput string `json:"user_input"` // 用户最终输入的内容
|
||||
IsAccept bool `json:"is_accept"` // 用户是否接受补全
|
||||
IsSuggested bool `json:"is_suggested"` // 是否为建议模式
|
||||
CodeLines int64 `json:"code_lines"` // 代码行数
|
||||
InputTokens int64 `json:"input_tokens"` // 输入token数
|
||||
OutputTokens int64 `json:"output_tokens"` // 输出token数
|
||||
CreatedAt int64 `json:"created_at"` // 创建时间戳
|
||||
UpdatedAt int64 `json:"updated_at"` // 更新时间戳
|
||||
TaskID string `json:"task_id"` // 任务ID
|
||||
UserID string `json:"user_id"` // 用户ID
|
||||
ModelID string `json:"model_id"` // 模型ID
|
||||
ModelName string `json:"model_name"` // 模型名称
|
||||
RequestID string `json:"request_id"` // 请求ID
|
||||
ModelType string `json:"model_type"` // 模型类型
|
||||
ProgramLanguage string `json:"program_language"` // 编程语言
|
||||
WorkMode string `json:"work_mode"` // 工作模式
|
||||
Prompt string `json:"prompt"` // 用户输入的提示
|
||||
Completion string `json:"completion"` // LLM生成的补全代码
|
||||
SourceCode string `json:"source_code"` // 当前文件原文
|
||||
CursorPosition map[string]any `json:"cursor_position"` // 光标位置 {"line": 10, "column": 5}
|
||||
UserInput string `json:"user_input"` // 用户最终输入的内容
|
||||
IsAccept bool `json:"is_accept"` // 用户是否接受补全
|
||||
IsSuggested bool `json:"is_suggested"` // 是否为建议模式
|
||||
CodeLines int64 `json:"code_lines"` // 代码行数
|
||||
InputTokens int64 `json:"input_tokens"` // 输入token数
|
||||
OutputTokens int64 `json:"output_tokens"` // 输出token数
|
||||
CreatedAt int64 `json:"created_at"` // 创建时间戳
|
||||
UpdatedAt int64 `json:"updated_at"` // 更新时间戳
|
||||
}
|
||||
|
||||
// ExportCompletionDataResp 导出补全数据响应
|
||||
|
||||
@@ -43,9 +43,9 @@ func (Task) Fields() []ent.Field {
|
||||
field.Int64("input_tokens").Optional(),
|
||||
field.Int64("output_tokens").Optional(),
|
||||
field.Bool("is_suggested").Default(false),
|
||||
field.String("source_code").Optional(), // 当前文件的原文
|
||||
field.JSON("cursor_position", map[string]interface{}{}).Optional(), // 光标位置 {"line": 10, "column": 5}
|
||||
field.String("user_input").Optional(), // 用户实际输入的内容
|
||||
field.String("source_code").Optional(), // 当前文件的原文
|
||||
field.JSON("cursor_position", map[string]any{}).Optional(), // 光标位置 {"line": 10, "column": 5}
|
||||
field.String("user_input").Optional(), // 用户实际输入的内容
|
||||
field.Time("created_at").Default(time.Now),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (r *Recorder) handleShadow() {
|
||||
|
||||
var (
|
||||
taskID, mode, prompt, language, tool, code, sourceCode, userInput string
|
||||
cursorPosition map[string]interface{}
|
||||
cursorPosition map[string]any
|
||||
)
|
||||
|
||||
switch r.ctx.Model.ModelType {
|
||||
@@ -99,7 +99,7 @@ func (r *Recorder) handleShadow() {
|
||||
// 解析cursor_position为JSON格式
|
||||
if posStr := req.Metadata["cursor_position"]; posStr != "" {
|
||||
if pos, err := strconv.ParseInt(posStr, 10, 64); err == nil {
|
||||
cursorPosition = map[string]interface{}{
|
||||
cursorPosition = map[string]any{
|
||||
"position": pos,
|
||||
"line": 1, // 默认值
|
||||
"column": pos,
|
||||
|
||||
@@ -476,7 +476,7 @@ func (r *UserRepo) ExportCompletionData(ctx context.Context) ([]*domain.Completi
|
||||
}
|
||||
|
||||
// 处理cursor_position(已经是JSON格式)
|
||||
var cursorPosition map[string]interface{}
|
||||
var cursorPosition map[string]any
|
||||
if t.CursorPosition != nil {
|
||||
cursorPosition = t.CursorPosition
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user