MCPcopy Create free account
hub / github.com/astercloud/aster / downloadTestImage

Function downloadTestImage

examples/custom_claude_api/test_vision.go:71–100  ·  view source on GitHub ↗

downloadTestImage 下载测试图片

()

Source from the content-addressed store, hash-verified

69
70// downloadTestImage 下载测试图片
71func downloadTestImage() ([]byte, string, error) {
72 // 使用 GitHub 的公开图片作为测试
73 imageURL := "https://avatars.githubusercontent.com/u/1?v=4"
74
75 client := &http.Client{
76 Timeout: 30 * time.Second,
77 }
78
79 resp, err := client.Get(imageURL)
80 if err != nil {
81 return nil, "", err
82 }
83 defer resp.Body.Close()
84
85 if resp.StatusCode != 200 {
86 return nil, "", fmt.Errorf("HTTP %d", resp.StatusCode)
87 }
88
89 data, err := io.ReadAll(resp.Body)
90 if err != nil {
91 return nil, "", err
92 }
93
94 mediaType := resp.Header.Get("Content-Type")
95 if mediaType == "" {
96 mediaType = "image/png"
97 }
98
99 return data, mediaType, nil
100}
101
102// testBasicVision 测试基础图片识别
103func testBasicVision(cp *provider.CustomClaudeProvider, imageData []byte, mediaType string) {

Callers 1

mainFunction · 0.85

Calls 2

GetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected