File size: 2,745 Bytes
7a2dc96
34d42e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0dfe7b
34d42e2
 
 
7a2dc96
34d42e2
 
 
 
7a2dc96
34d42e2
 
 
 
 
 
 
 
 
 
7a2dc96
34d42e2
 
 
 
7a2dc96
34d42e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a2dc96
34d42e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
86
87
88
89
90
91
92
93
94
95
import { IModelInfo } from '../interface';
import axios from 'axios';

// Search engine related. You don't really need to change this.
export const EndPoint = {
  BING_SEARCH_V7_ENDPOINT: 'https://api.bing.microsoft.com/v7.0/search',
  GOOGLE_SEARCH_ENDPOINT: 'https://www.googleapis.com/customsearch/v1'
};

export const BING_MKT = 'en-US';

// default timeout ms
export const DEFAULT_SEARCH_ENGINE_TIMEOUT = 20000;

// default search keywords
export const DefaultQuery = 'Who said \'live long and prosper';
export const DefaultSystem = 'You are a helpful assistant.';

// 创建一个异步函数来获取模型列表
async function fetchOpenAIModels(): Promise<string[]> {
  try {
    const response = await axios.get('https://api.deem.love/v1/models');
    const data = response.data;
    return data.data.map((model: { id: string }) => model.id);
  } catch (error) {
    console.error('获取模型列表失败:', error);
    return [];
  }
}

// 修改 Models 数组,将 'openai' 平台的模型设置为动态获取
export let Models: IModelInfo[] = [
  {
    platform: 'aliyun',
    type: '',
    models: ['qwen-max', 'qwen-max-0428', 'qwen-turbo', 'qwen-plus']
  },
  {
    platform: 'openai',
    type: 'openai',
    //models: ['gpt-4o', 'gpt-4o-mini', 'chatgpt-4o-latest', 'gpt-3.5-turbo', 'gpt-4-preview', 'gpt-4-turbo', 'gpt-4']
    models: [] // 初始为空数组,稍后动态填充
  },
  {
    platform: 'baidu',
    type: 'baidu',
    models: ['eb-instant', 'completions_pro', 'ernie_bot_8k']
  },
  {
    platform: 'google',
    type: 'gemini',
    models: ['gemini-1.0-pro', 'gemini-1.5-pro', 'gemini-1.5-flash']
  },
  {
    platform: 'yi',
    type: 'openai',
    models: ['yi-large', 'yi-large-turbo', 'yi-medium', 'yi-spark']
  },
  {
    platform: 'moonshot',
    type: 'openai',
    models: ['moonshot-v1-8k', 'moonshot-v1-32k', 'moonshot-v1-128k']
  },
  {
    platform: 'lepton',
    type: 'openai',
    models: ['llama2-7b', 'llama2-13b', 'llama2-70b', 'mixtral-8*7b', 'mixtral-8*22b']
  },
  {
    platform: 'deepseek',
    type: 'openai',
    models: ['deepseek-chat', 'deepseek-coder']
  },
  {
    platform: 'chatglm',
    type: 'openai',
    models: ['glm-4', 'glm-4-plus', 'glm-4-air', 'glm-4-airx', 'glm-4-flash']
  },
  {
    platform: 'tencent',
    type: 'tencent',
    models: ['std', 'pro']
  }
];

// 创建一个初始化函数来更新 Models 数组
export async function initializeModels() {
  const openAIModels = await fetchOpenAIModels();
  Models = Models.map(platform => {
    if (platform.platform === 'openai') {
      return { ...platform, models: openAIModels };
    }
    return platform;
  });
}