KevinHuSh commited on
Commit
73099c4
·
1 Parent(s): c57f28e

support gpt-4o (#773)

Browse files

### What problem does this PR solve?
#771

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

api/apps/llm_app.py CHANGED
@@ -194,7 +194,7 @@ def list_app():
194
 
195
  res = {}
196
  for m in llms:
197
- if model_type and m["model_type"] != model_type:
198
  continue
199
  if m["fid"] not in res:
200
  res[m["fid"]] = []
 
194
 
195
  res = {}
196
  for m in llms:
197
+ if model_type and m["model_type"].find(model_type)<0:
198
  continue
199
  if m["fid"] not in res:
200
  res[m["fid"]] = []
api/db/init_data.py CHANGED
@@ -143,6 +143,12 @@ def init_llm_factory():
143
  llm_infos = [
144
  # ---------------------- OpenAI ------------------------
145
  {
 
 
 
 
 
 
146
  "fid": factory_infos[0]["name"],
147
  "llm_name": "gpt-3.5-turbo",
148
  "tags": "LLM,CHAT,4K",
 
143
  llm_infos = [
144
  # ---------------------- OpenAI ------------------------
145
  {
146
+ "fid": factory_infos[0]["name"],
147
+ "llm_name": "gpt-4o",
148
+ "tags": "LLM,CHAT,128K",
149
+ "max_tokens": 128000,
150
+ "model_type": LLMType.CHAT.value + "," + LLMType.IMAGE2TEXT.value
151
+ }, {
152
  "fid": factory_infos[0]["name"],
153
  "llm_name": "gpt-3.5-turbo",
154
  "tags": "LLM,CHAT,4K",
api/db/services/llm_service.py CHANGED
@@ -81,7 +81,7 @@ class TenantLLMService(CommonService):
81
  if not model_config:
82
  if llm_type == LLMType.EMBEDDING.value:
83
  llm = LLMService.query(llm_name=llm_name)
84
- if llm and llm[0].fid in ["Youdao", "FastEmbed"]:
85
  model_config = {"llm_factory": llm[0].fid, "api_key":"", "llm_name": llm_name, "api_base": ""}
86
  if not model_config:
87
  if llm_name == "flag-embedding":
 
81
  if not model_config:
82
  if llm_type == LLMType.EMBEDDING.value:
83
  llm = LLMService.query(llm_name=llm_name)
84
+ if llm and llm[0].fid in ["Youdao", "FastEmbed", "DeepSeek"]:
85
  model_config = {"llm_factory": llm[0].fid, "api_key":"", "llm_name": llm_name, "api_base": ""}
86
  if not model_config:
87
  if llm_name == "flag-embedding":
api/settings.py CHANGED
@@ -86,6 +86,12 @@ default_llm = {
86
  "embedding_model": "",
87
  "image2text_model": "",
88
  "asr_model": "",
 
 
 
 
 
 
89
  }
90
  }
91
  LLM = get_base_config("user_default_llm", {})
 
86
  "embedding_model": "",
87
  "image2text_model": "",
88
  "asr_model": "",
89
+ },
90
+ "DeepSeek": {
91
+ "chat_model": "deepseek-chat",
92
+ "embedding_model": "BAAI/bge-large-zh-v1.5",
93
+ "image2text_model": "",
94
+ "asr_model": "",
95
  }
96
  }
97
  LLM = get_base_config("user_default_llm", {})
rag/llm/__init__.py CHANGED
@@ -25,7 +25,8 @@ EmbeddingModel = {
25
  "Tongyi-Qianwen": DefaultEmbedding, #QWenEmbed,
26
  "ZHIPU-AI": ZhipuEmbed,
27
  "FastEmbed": FastEmbed,
28
- "Youdao": YoudaoEmbed
 
29
  }
30
 
31
 
 
25
  "Tongyi-Qianwen": DefaultEmbedding, #QWenEmbed,
26
  "ZHIPU-AI": ZhipuEmbed,
27
  "FastEmbed": FastEmbed,
28
+ "Youdao": YoudaoEmbed,
29
+ "DeepSeek": DefaultEmbedding
30
  }
31
 
32
 
rag/svr/task_executor.py CHANGED
@@ -261,7 +261,7 @@ def main():
261
 
262
  st = timer()
263
  cks = build(r)
264
- cron_logger.info("Build chunks({}): {}".format(r["name"], timer()-st))
265
  if cks is None:
266
  continue
267
  if not cks:
@@ -279,7 +279,7 @@ def main():
279
  callback(-1, "Embedding error:{}".format(str(e)))
280
  cron_logger.error(str(e))
281
  tk_count = 0
282
- cron_logger.info("Embedding elapsed({}): {}".format(r["name"], timer()-st))
283
 
284
  callback(msg="Finished embedding({:.2f})! Start to build index!".format(timer()-st))
285
  init_kb(r)
@@ -291,7 +291,7 @@ def main():
291
  if b % 128 == 0:
292
  callback(prog=0.8 + 0.1 * (b + 1) / len(cks), msg="")
293
 
294
- cron_logger.info("Indexing elapsed({}): {}".format(r["name"], timer()-st))
295
  if es_r:
296
  callback(-1, "Index failure!")
297
  ELASTICSEARCH.deleteByQuery(
@@ -306,7 +306,7 @@ def main():
306
  DocumentService.increment_chunk_num(
307
  r["doc_id"], r["kb_id"], tk_count, chunk_count, 0)
308
  cron_logger.info(
309
- "Chunk doc({}), token({}), chunks({}), elapsed:{}".format(
310
  r["id"], tk_count, len(cks), timer()-st))
311
 
312
 
 
261
 
262
  st = timer()
263
  cks = build(r)
264
+ cron_logger.info("Build chunks({}): {:.2f}".format(r["name"], timer()-st))
265
  if cks is None:
266
  continue
267
  if not cks:
 
279
  callback(-1, "Embedding error:{}".format(str(e)))
280
  cron_logger.error(str(e))
281
  tk_count = 0
282
+ cron_logger.info("Embedding elapsed({:.2f}): {}".format(r["name"], timer()-st))
283
 
284
  callback(msg="Finished embedding({:.2f})! Start to build index!".format(timer()-st))
285
  init_kb(r)
 
291
  if b % 128 == 0:
292
  callback(prog=0.8 + 0.1 * (b + 1) / len(cks), msg="")
293
 
294
+ cron_logger.info("Indexing elapsed({}): {:.2f}".format(r["name"], timer()-st))
295
  if es_r:
296
  callback(-1, "Index failure!")
297
  ELASTICSEARCH.deleteByQuery(
 
306
  DocumentService.increment_chunk_num(
307
  r["doc_id"], r["kb_id"], tk_count, chunk_count, 0)
308
  cron_logger.info(
309
+ "Chunk doc({}), token({}), chunks({}), elapsed:{:.2f}".format(
310
  r["id"], tk_count, len(cks), timer()-st))
311
 
312