admin
2025-06-06 9cd825aea53fa5ba0cda1485464af027e27f0ce4
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
package tech.aiflowy.ai.entity;
 
import tech.aiflowy.common.util.StringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.List;
 
public class AiLlmBrand implements Serializable {
 
    private String title;
    private String icon;
    private String key;
 
    public String getTitle() {
        return title;
    }
 
    public void setTitle(String title) {
        this.title = title;
    }
 
    public String getIcon() {
        return icon;
    }
 
    public void setIcon(String icon) {
        this.icon = icon;
    }
 
    public String getKey() {
        return key;
    }
 
    public void setKey(String key) {
        this.key = key;
    }
 
    public static List<AiLlmBrand> fromJsonConfig() {
        Resource resource = new ClassPathResource("ai-brands.json");
        try (InputStream is = resource.getInputStream();
             BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
            StringBuilder jsonString = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                jsonString.append(line);
            }
 
            String json = jsonString.toString().trim();
            if (StringUtil.hasText(json)) {
                JSONArray jsonArray = JSON.parseArray(json);
                return jsonArray.toJavaList(AiLlmBrand.class);
            }
            return null;
        } catch (Exception e) {
            LoggerFactory.getLogger(AiLlmBrand.class).error(e.toString(), e);
            return null;
        }
    }
}