Files

1 line
20 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "3395444278/qiniu", "files": {"internal/pkg/ai/client.go": {"50419f8f4007eee042d4704ca94bec9d0a9883dc": {"t": 1785746073.4153466, "n": 4819, "h": "1c8a79d117a8f7e4", "c": "package ai\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype Client struct {\n\tapiKey string\n\tapiBaseURL string\n\tmodel string\n}\n\nfunc NewClient(apiKey string) *Client {\n\tlog.Printf(\"Initializing AI client with key: %s...\", apiKey[:10])\n\n\treturn &Client{\n\t\tapiKey: apiKey,\n\t\tapiBaseURL: \"https://api.deepseek.com/chat/completions\",\n\t\tmodel: \"deepseek-chat\",\n\t}\n}\n\ntype Message struct {\n\tRole string `json:\"role\"`\n\tContent string `json:\"content\"`\n}\n\ntype ChatRequest struct {\n\tModel string `json:\"model\"`\n\tMessages []Message `json:\"messages\"`\n\tStream bool `json:\"stream\"`\n}\n\ntype ChatResponse struct {\n\tChoices []struct {\n\t\tMessage struct {\n\t\t\tContent string `json:\"content\"`\n\t\t} `json:\"message\"`\n\t} `json:\"choices\"`\n}\n\nfunc (c *Client) EvaluateDeveloper(ctx context.Context, info map[string]interface{}) (*EvaluationResult, error) {\n\tprompt := buildEvaluationPrompt(info)\n\n\trequest := ChatRequest{\n\t\tModel: c.model,\n\t\tMessages: []Message{\n\t\t\t{\n\t\t\t\tRole: \"system\",\n\t\t\t\tContent: \"你是一个专业的技术人才评估专家。请根据提供的信息评估开发者的技术能力,并以 JSON 格式返回评估结果。\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tRole: \"user\",\n\t\t\t\tContent: prompt,\n\t\t\t},\n\t\t},\n\t\tStream: false,\n\t}\n\n\treqBody, err := json.Marshal(request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request: %v\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", c.apiBaseURL, bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create request: %v\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", c.apiKey))\n\n\tlog.Printf(\"Sending request to DeepSeek API with URL: %s\", c.apiBaseURL)\n\tlog.Printf(\"Request headers: %+v\", req.Header)\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to send request: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tlog.Printf(\"DeepSeek API response status: %d\", resp.StatusCode)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn nil, fmt.Errorf(\"DeepSeek API returned status code %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar chatResp ChatResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&chatResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode response: %v\", err)\n\t}\n\n\tif len(chatResp.Choices) == 0 {\n\t\treturn nil, fmt.Errorf(\"no response from DeepSeek API\")\n\t}\n\n\tlog.Printf(\"DeepSeek API Response: %s\", chatResp.Choices[0].Message.Content)\n\n\tresult, err := parseAIResponse(chatResp.Choices[0].Message.Content)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse AI response: %v\", err)\n\t}\n\n\treturn result, nil\n}\n\nfunc buildEvaluationPrompt(info map[string]interface{}) string {\n\treturn fmt.Sprintf(`请根据以下信息评估该开发者的技术能力,重点分析其可能所在的国家/地区。请特别关注:\n1. 用户名特征\n2. 代码注释语言\n3. 项目描述语言\n4. 技术栈特点\n5. 活跃时间规律\n\n开发者信息:\n- 用户名:%v\n- 名称:%v\n- 邮箱:%v\n- 位置:%v\n- GitHub主页:%v\n- 技术栈:%v\n- 编程语言:%v\n- 主要仓库:%v\n- 提交数:%v\n- Stars数:%v\n- Forks数:%v\n- 最近活跃:%v\n\n请以JSON格式返回以下信息:\n{\n \"nation\": \"CN\", // 两位国家代码:CN中国,US美国,JP日本,KR韩国,SG新加坡等\n \"confidence\": 85, // 置信度0-100\n \"reasons\": [\"原因1\", \"原因2\"], // 判断依据\n \"specialties\": [\"专长1\", \"专长2\"],\n \"evaluation\": \"整体评价\"\n}`,\n\t\tinfo[\"username\"], info[\"name\"], info[\"email\"], info[\"location\"],\n\t\tinfo[\"profile_url\"], info[\"skills\"], info[\"languages\"],\n\t\tinfo[\"repos\"], info[\"commits\"], info[\"stars\"],\n\t\tinfo[\"forks\"], info[\"last_active\"])\n}\n\ntype EvaluationResult struct {\n\tSpecialties []string `json:\"specialties\"`\n\tExperience map[string]string `json:\"experience\"`\n\tAIEvaluation string `json:\"evaluation\"`\n\tNation string `json:\"nation\"`\n\tConfidence float64 `json:\"confidence\"`\n\tLastEvaluated time.Time `json:\"last_evaluated\"`\n}\n\nfunc parseAIResponse(response string) (*EvaluationResult, error) {\n\tlog.Printf(\"Raw AI response: %s\", response)\n\n\tcleanedResponse := response\n\tif strings.Contains(response, \"```json\") {\n\t\tstart := strings.Index(response, \"```json\\n\") + 8\n\t\tend := strings.Index(response[start:], \"```\")\n\t\tif end != -1 {\n\t\t\tcleanedResponse = response[start : start+end]\n\t\t}\n\t}\n\n\t// 定义一个临时结构体来解析完整的响应\n\tvar temp struct {\n\t\tNation string `json:\"nation\"`\n\t\tConfidence float64 `json:\"confidence\"`\n\t\tReasons []string `json:\"reasons\"`\n\t\tSpecialties []string `json:\"specialties\"`\n\t\tEvaluation string `json:\"evaluation\"`\n\t}\n\n\tif err := json.Unmarshal([]byte(cleanedResponse), &temp); err != nil {\n\t\tlog.Printf(\"Error parsing AI response: %v\", err)\n\t\treturn nil, fmt.Errorf(\"解析 AI 响应失败: %v\", err)\n\t}\n\n\t// 转换为 EvaluationResult\n\tresult := &EvaluationResult{\n\t\tSpecialties: temp.Specialties,\n\t\tExperience: make(map[string]string),\n\t\tAIEvaluation: temp.Evaluation,\n\t\tNation: temp.Nation,\n\t\tConfidence: temp.Confidence,\n\t\tLastEvaluated: time.Now(),\n\t}\n\n\treturn result, nil\n}\n"}, "1c9c633cc55b8642ae4804c7ccfba1dfe38715df": {"t": 1785759521.525978, "n": 4819, "h": "1c8a79d117a8f7e4", "c": "package ai\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype Client struct {\n\tapiKey string\n\tapiBaseURL string\n\tmodel string\n}\n\nfunc NewClient(apiKey string) *Client {\n\tlog.Printf(\"Initializing AI client with key: %s...\", apiKey[:10])\n\n\treturn &Client{\n\t\tapiKey: apiKey,\n\t\tapiBaseURL: \"https://api.deepseek.com/chat/completions\",\n\t\tmodel: \"deepseek-chat\",\n\t}\n}\n\ntype Message struct {\n\tRole string `json:\"role\"`\n\tContent string `json:\"content\"`\n}\n\ntype ChatRequest struct {\n\tModel string `json:\"model\"`\n\tMessages []Message `json:\"messages\"`\n\tStream bool `json:\"stream\"`\n}\n\ntype ChatResponse struct {\n\tChoices []struct {\n\t\tMessage struct {\n\t\t\tContent string `json:\"content\"`\n\t\t} `json:\"message\"`\n\t} `json:\"choices\"`\n}\n\nfunc (c *Client) EvaluateDeveloper(ctx context.Context, info map[string]interface{}) (*EvaluationResult, error) {\n\tprompt := buildEvaluationPrompt(info)\n\n\trequest := ChatRequest{\n\t\tModel: c.model,\n\t\tMessages: []Message{\n\t\t\t{\n\t\t\t\tRole: \"system\",\n\t\t\t\tContent: \"你是一个专业的技术人才评估专家。请根据提供的信息评估开发者的技术能力,并以 JSON 格式返回评估结果。\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tRole: \"user\",\n\t\t\t\tContent: prompt,\n\t\t\t},\n\t\t},\n\t\tStream: false,\n\t}\n\n\treqBody, err := json.Marshal(request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request: %v\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", c.apiBaseURL, bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create request: %v\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", c.apiKey))\n\n\tlog.Printf(\"Sending request to DeepSeek API with URL: %s\", c.apiBaseURL)\n\tlog.Printf(\"Request headers: %+v\", req.Header)\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to send request: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tlog.Printf(\"DeepSeek API response status: %d\", resp.StatusCode)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn nil, fmt.Errorf(\"DeepSeek API returned status code %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar chatResp ChatResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&chatResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode response: %v\", err)\n\t}\n\n\tif len(chatResp.Choices) == 0 {\n\t\treturn nil, fmt.Errorf(\"no response from DeepSeek API\")\n\t}\n\n\tlog.Printf(\"DeepSeek API Response: %s\", chatResp.Choices[0].Message.Content)\n\n\tresult, err := parseAIResponse(chatResp.Choices[0].Message.Content)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse AI response: %v\", err)\n\t}\n\n\treturn result, nil\n}\n\nfunc buildEvaluationPrompt(info map[string]interface{}) string {\n\treturn fmt.Sprintf(`请根据以下信息评估该开发者的技术能力,重点分析其可能所在的国家/地区。请特别关注:\n1. 用户名特征\n2. 代码注释语言\n3. 项目描述语言\n4. 技术栈特点\n5. 活跃时间规律\n\n开发者信息:\n- 用户名:%v\n- 名称:%v\n- 邮箱:%v\n- 位置:%v\n- GitHub主页:%v\n- 技术栈:%v\n- 编程语言:%v\n- 主要仓库:%v\n- 提交数:%v\n- Stars数:%v\n- Forks数:%v\n- 最近活跃:%v\n\n请以JSON格式返回以下信息:\n{\n \"nation\": \"CN\", // 两位国家代码:CN中国,US美国,JP日本,KR韩国,SG新加坡等\n \"confidence\": 85, // 置信度0-100\n \"reasons\": [\"原因1\", \"原因2\"], // 判断依据\n \"specialties\": [\"专长1\", \"专长2\"],\n \"evaluation\": \"整体评价\"\n}`,\n\t\tinfo[\"username\"], info[\"name\"], info[\"email\"], info[\"location\"],\n\t\tinfo[\"profile_url\"], info[\"skills\"], info[\"languages\"],\n\t\tinfo[\"repos\"], info[\"commits\"], info[\"stars\"],\n\t\tinfo[\"forks\"], info[\"last_active\"])\n}\n\ntype EvaluationResult struct {\n\tSpecialties []string `json:\"specialties\"`\n\tExperience map[string]string `json:\"experience\"`\n\tAIEvaluation string `json:\"evaluation\"`\n\tNation string `json:\"nation\"`\n\tConfidence float64 `json:\"confidence\"`\n\tLastEvaluated time.Time `json:\"last_evaluated\"`\n}\n\nfunc parseAIResponse(response string) (*EvaluationResult, error) {\n\tlog.Printf(\"Raw AI response: %s\", response)\n\n\tcleanedResponse := response\n\tif strings.Contains(response, \"```json\") {\n\t\tstart := strings.Index(response, \"```json\\n\") + 8\n\t\tend := strings.Index(response[start:], \"```\")\n\t\tif end != -1 {\n\t\t\tcleanedResponse = response[start : start+end]\n\t\t}\n\t}\n\n\t// 定义一个临时结构体来解析完整的响应\n\tvar temp struct {\n\t\tNation string `json:\"nation\"`\n\t\tConfidence float64 `json:\"confidence\"`\n\t\tReasons []string `json:\"reasons\"`\n\t\tSpecialties []string `json:\"specialties\"`\n\t\tEvaluation string `json:\"evaluation\"`\n\t}\n\n\tif err := json.Unmarshal([]byte(cleanedResponse), &temp); err != nil {\n\t\tlog.Printf(\"Error parsing AI response: %v\", err)\n\t\treturn nil, fmt.Errorf(\"解析 AI 响应失败: %v\", err)\n\t}\n\n\t// 转换为 EvaluationResult\n\tresult := &EvaluationResult{\n\t\tSpecialties: temp.Specialties,\n\t\tExperience: make(map[string]string),\n\t\tAIEvaluation: temp.Evaluation,\n\t\tNation: temp.Nation,\n\t\tConfidence: temp.Confidence,\n\t\tLastEvaluated: time.Now(),\n\t}\n\n\treturn result, nil\n}\n"}, "99c7ad9c39d45dbf90b0ada3634bc230d852f4dc": {"t": 1785759523.3443706, "n": 6697, "h": "5effdf917be9d906", "c": "package ai\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype Client struct {\n\tapiKey string\n\tapiBaseURL string\n\tmodel string\n}\n\nfunc NewClient(apiKey string) *Client {\n\tlog.Printf(\"Initializing AI client with key: %s...\", apiKey[:10])\n\n\treturn &Client{\n\t\tapiKey: apiKey,\n\t\tapiBaseURL: \"https://api.deepseek.com/chat/completions\",\n\t\tmodel: \"deepseek-chat\",\n\t}\n}\n\ntype Message struct {\n\tRole string `json:\"role\"`\n\tContent string `json:\"content\"`\n}\n\ntype ChatRequest struct {\n\tModel string `json:\"model\"`\n\tMessages []Message `json:\"messages\"`\n\tStream bool `json:\"stream\"`\n}\n\ntype ChatResponse struct {\n\tChoices []struct {\n\t\tMessage struct {\n\t\t\tContent string `json:\"content\"`\n\t\t} `json:\"message\"`\n\t} `json:\"choices\"`\n}\n\nfunc (c *Client) EvaluateDeveloper(ctx context.Context, info map[string]interface{}) (*EvaluationResult, error) {\n\tprompt := buildEvaluationPrompt(info)\n\n\trequest := ChatRequest{\n\t\tModel: c.model,\n\t\tMessages: []Message{\n\t\t\t{\n\t\t\t\tRole: \"system\",\n\t\t\t\tContent: \"你是一个专业的技术人才评估专家。请根据提供的信息评估开发者的技术能力,并以 JSON 格式返回评估结果。\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tRole: \"user\",\n\t\t\t\tContent: prompt,\n\t\t\t},\n\t\t},\n\t\tStream: false,\n\t}\n\n\treqBody, err := json.Marshal(request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request: %v\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", c.apiBaseURL, bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create request: %v\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", c.apiKey))\n\n\tlog.Printf(\"Sending request to DeepSeek API with URL: %s\", c.apiBaseURL)\n\tlog.Printf(\"Request headers: %+v\", req.Header)\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to send request: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tlog.Printf(\"DeepSeek API response status: %d\", resp.StatusCode)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn nil, fmt.Errorf(\"DeepSeek API returned status code %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar chatResp ChatResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&chatResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode response: %v\", err)\n\t}\n\n\tif len(chatResp.Choices) == 0 {\n\t\treturn nil, fmt.Errorf(\"no response from DeepSeek API\")\n\t}\n\n\tlog.Printf(\"DeepSeek API Response: %s\", chatResp.Choices[0].Message.Content)\n\n\tresult, err := parseAIResponse(chatResp.Choices[0].Message.Content)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse AI response: %v\", err)\n\t}\n\n\treturn result, nil\n}\n\nfunc buildEvaluationPrompt(info map[string]interface{}) string {\n\treturn fmt.Sprintf(`请根据以下信息全面评估该开发者的技术能力,并以 JSON 格式返回评估结果:\n\n开发者基本信息:\n- 用户名:%v\n- 姓名:%v\n- 简介:%v\n- 位置:%v\n- 邮箱:%v\n\n在线资料:\n- GitHub 主页:%v\n- 博客:%v\n- 个人网站:%v\n\n技术信息:\n- 技术栈:%v\n- 编程语言:%v\n- 主要仓库:%v\n- 仓库链接:%v\n\n贡献统计:\n- Stars 总数:%v\n- Commits 总数:%v\n- Forks 总数:%v\n- 各仓库 Stars:%v\n\n活跃度:\n- 最近活跃:%v\n- 账号创建:%v\n- 最后更新:%v\n\n请返回以下格式的 JSON:\n{\n \"specialties\": [\"主要专长领域1\", \"主要专长领域2\", ...],\n \"experience\": {\n \"技术1\": \"详细的经验评估\",\n \"技术2\": \"详细的经验评估\",\n ...\n },\n \"evaluation\": \"全面的技术能力评价,包括技术深度、广度、项目质量等方面\"\n}\n`,\n\t\tinfo[\"username\"], info[\"name\"], info[\"bio\"], info[\"location\"], info[\"email\"],\n\t\tinfo[\"profile_url\"], info[\"blog\"], info[\"personal_site\"],\n\t\tinfo[\"skills\"], info[\"languages\"], info[\"repos\"], info[\"repo_urls\"],\n\t\tinfo[\"stars\"], info[\"commits\"], info[\"forks\"], info[\"repo_stars\"],\n\t\tinfo[\"last_active\"], info[\"created_at\"], info[\"updated_at\"])\n}\n\ntype EvaluationResult struct {\n\tSpecialties []string `json:\"specialties\"`\n\tExperience map[string]string `json:\"experience\"`\n\tAIEvaluation string `json:\"evaluation\"`\n\tLastEvaluated time.Time `json:\"last_evaluated\"`\n}\n\nfunc parseAIResponse(response string) (*EvaluationResult, error) {\n\tlog.Printf(\"Raw AI response: %s\", response)\n\n\t// 首先尝试清理响应中的 JSON 字符串\n\tcleanedResponse := response\n\tif strings.Contains(response, \"```json\") {\n\t\t// 提取 JSON 部分\n\t\tstart := strings.Index(response, \"```json\\n\") + 8\n\t\tend := strings.Index(response[start:], \"```\")\n\t\tif end != -1 {\n\t\t\tcleanedResponse = response[start : start+end]\n\t\t}\n\t}\n\n\t// 尝试解析 JSON\n\tvar result struct {\n\t\tSpecialties []string `json:\"specialties\"`\n\t\tExperience map[string]string `json:\"experience\"`\n\t\tEvaluation string `json:\"evaluation\"`\n\t}\n\n\tif err := json.Unmarshal([]byte(cleanedResponse), &result); err != nil {\n\t\tlog.Printf(\"Error parsing AI response: %v\", err)\n\n\t\t// 如果解析失败,尝试提取有用信息\n\t\tspecialties := extractSpecialties(response)\n\t\texperience := extractExperience(response)\n\t\tevaluation := extractEvaluation(response)\n\n\t\t// 确保返回的 map 不为 nil\n\t\tif experience == nil {\n\t\t\texperience = make(map[string]string)\n\t\t}\n\n\t\t// 返回提取的信息\n\t\treturn &EvaluationResult{\n\t\t\tSpecialties: specialties,\n\t\t\tExperience: experience,\n\t\t\tAIEvaluation: evaluation,\n\t\t\tLastEvaluated: time.Now(),\n\t\t}, nil\n\t}\n\n\t// 确保返回的 map 不为 nil\n\tif result.Experience == nil {\n\t\tresult.Experience = make(map[string]string)\n\t}\n\tif result.Specialties == nil {\n\t\tresult.Specialties = make([]string, 0)\n\t}\n\n\t// JSON 解析成功\n\treturn &EvaluationResult{\n\t\tSpecialties: result.Specialties,\n\t\tExperience: result.Experience,\n\t\tAIEvaluation: result.Evaluation,\n\t\tLastEvaluated: time.Now(),\n\t}, nil\n}\n\n// 辅助函数:提取专长信息\nfunc extractSpecialties(text string) []string {\n\tspecialties := make([]string, 0)\n\tre := regexp.MustCompile(`专长[::]\\s*(.*?)(?:\\n|$)`)\n\tmatches := re.FindStringSubmatch(text)\n\tif len(matches) > 1 {\n\t\t// 分割并清理结果\n\t\tfor _, s := range strings.Split(matches[1], \",\") {\n\t\t\ts = strings.TrimSpace(s)\n\t\t\tif s != \"\" {\n\t\t\t\tspecialties = append(specialties, s)\n\t\t\t}\n\t\t}\n\t}\n\treturn specialties\n}\n\n// 辅助函数:提取经验信息\nfunc extractExperience(text string) map[string]string {\n\texperience := make(map[string]string)\n\tre := regexp.MustCompile(`(\\w+)[::]\\s*(.*?)(?:\\n|$)`)\n\tmatches := re.FindAllStringSubmatch(text, -1)\n\tfor _, match := range matches {\n\t\tif len(match) > 2 {\n\t\t\ttech := strings.TrimSpace(match[1])\n\t\t\tlevel := strings.TrimSpace(match[2])\n\t\t\tif tech != \"\" && level != \"\" {\n\t\t\t\texperience[tech] = level\n\t\t\t}\n\t\t}\n\t}\n\treturn experience\n}\n\n// 辅助函数:提取评估信息\nfunc extractEvaluation(text string) string {\n\t// 首先尝试提取 evaluation 字段\n\tvar result struct {\n\t\tEvaluation string `json:\"evaluation\"`\n\t}\n\tif err := json.Unmarshal([]byte(text), &result); err == nil && result.Evaluation != \"\" {\n\t\treturn result.Evaluation\n\t}\n\n\t// 如果失败,尝试使用正则表达式\n\tre := regexp.MustCompile(`评[价估][::]\\s*(.*?)(?:\\n|$)`)\n\tmatches := re.FindStringSubmatch(text)\n\tif len(matches) > 1 {\n\t\treturn strings.TrimSpace(matches[1])\n\t}\n\n\t// 如果都失败了,返回整个文本\n\treturn strings.TrimSpace(text)\n}\n"}}}}