KevinHuSh commited on
Commit
df17cda
·
1 Parent(s): 447b19b

add version (#807)

Browse files

### What problem does this PR solve?
#709
### Type of change

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

Files changed (3) hide show
  1. Dockerfile +1 -0
  2. api/db/services/kb_service.py +0 -67
  3. api/versions.py +4 -6
Dockerfile CHANGED
@@ -15,6 +15,7 @@ ENV PYTHONPATH=/ragflow/
15
  ENV HF_ENDPOINT=https://hf-mirror.com
16
 
17
  ADD docker/entrypoint.sh ./entrypoint.sh
 
18
  RUN chmod +x ./entrypoint.sh
19
 
20
  ENTRYPOINT ["./entrypoint.sh"]
 
15
  ENV HF_ENDPOINT=https://hf-mirror.com
16
 
17
  ADD docker/entrypoint.sh ./entrypoint.sh
18
+ ADD docker/.env ./
19
  RUN chmod +x ./entrypoint.sh
20
 
21
  ENTRYPOINT ["./entrypoint.sh"]
api/db/services/kb_service.py DELETED
@@ -1,67 +0,0 @@
1
- #
2
- # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- from api.db import TenantPermission
18
- from api.db.db_models import DB, Tenant
19
- from api.db.db_models import Knowledgebase
20
- from api.db.services.common_service import CommonService
21
- from api.db import StatusEnum
22
-
23
-
24
- class KnowledgebaseService(CommonService):
25
- model = Knowledgebase
26
-
27
- @classmethod
28
- @DB.connection_context()
29
- def get_by_tenant_ids(cls, joined_tenant_ids, user_id,
30
- page_number, items_per_page, orderby, desc):
31
- kbs = cls.model.select().where(
32
- ((cls.model.tenant_id.in_(joined_tenant_ids) & (cls.model.permission ==
33
- TenantPermission.TEAM.value)) | (cls.model.tenant_id == user_id))
34
- & (cls.model.status == StatusEnum.VALID.value)
35
- )
36
- if desc:
37
- kbs = kbs.order_by(cls.model.getter_by(orderby).desc())
38
- else:
39
- kbs = kbs.order_by(cls.model.getter_by(orderby).asc())
40
-
41
- kbs = kbs.paginate(page_number, items_per_page)
42
-
43
- return list(kbs.dicts())
44
-
45
- @classmethod
46
- @DB.connection_context()
47
- def get_detail(cls, kb_id):
48
- fields = [
49
- cls.model.id,
50
- Tenant.embd_id,
51
- cls.model.avatar,
52
- cls.model.name,
53
- cls.model.description,
54
- cls.model.permission,
55
- cls.model.doc_num,
56
- cls.model.token_num,
57
- cls.model.chunk_num,
58
- cls.model.parser_id]
59
- kbs = cls.model.select(*fields).join(Tenant, on=((Tenant.id == cls.model.tenant_id)&(Tenant.status== StatusEnum.VALID.value))).where(
60
- (cls.model.id == kb_id),
61
- (cls.model.status == StatusEnum.VALID.value)
62
- )
63
- if not kbs:
64
- return
65
- d = kbs[0].to_dict()
66
- d["embd_id"] = kbs[0].tenant.embd_id
67
- return d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
api/versions.py CHANGED
@@ -14,17 +14,15 @@
14
  # limitations under the License.
15
  #
16
  import os
17
-
18
  import dotenv
19
  import typing
20
-
21
  from api.utils.file_utils import get_project_base_directory
22
 
23
 
24
  def get_versions() -> typing.Mapping[str, typing.Any]:
25
- return dotenv.dotenv_values(
26
- dotenv_path=os.path.join(get_project_base_directory(), "rag.env")
27
- )
28
 
29
  def get_rag_version() -> typing.Optional[str]:
30
- return get_versions().get("RAG")
 
14
  # limitations under the License.
15
  #
16
  import os
 
17
  import dotenv
18
  import typing
 
19
  from api.utils.file_utils import get_project_base_directory
20
 
21
 
22
  def get_versions() -> typing.Mapping[str, typing.Any]:
23
+ dotenv.load_dotenv(dotenv.find_dotenv())
24
+ return dotenv.dotenv_values()
25
+
26
 
27
  def get_rag_version() -> typing.Optional[str]:
28
+ return get_versions().get("RAGFLOW_VERSION", "dev")