mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-04 14:05:13 +08:00
add version (#807)
### What problem does this PR solve? #709 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
63ca15c595
commit
d6772f5dd7
@ -15,6 +15,7 @@ ENV PYTHONPATH=/ragflow/
|
|||||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||||
|
|
||||||
ADD docker/entrypoint.sh ./entrypoint.sh
|
ADD docker/entrypoint.sh ./entrypoint.sh
|
||||||
|
ADD docker/.env ./
|
||||||
RUN chmod +x ./entrypoint.sh
|
RUN chmod +x ./entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
ENTRYPOINT ["./entrypoint.sh"]
|
@ -1,67 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
from api.db import TenantPermission
|
|
||||||
from api.db.db_models import DB, Tenant
|
|
||||||
from api.db.db_models import Knowledgebase
|
|
||||||
from api.db.services.common_service import CommonService
|
|
||||||
from api.db import StatusEnum
|
|
||||||
|
|
||||||
|
|
||||||
class KnowledgebaseService(CommonService):
|
|
||||||
model = Knowledgebase
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
@DB.connection_context()
|
|
||||||
def get_by_tenant_ids(cls, joined_tenant_ids, user_id,
|
|
||||||
page_number, items_per_page, orderby, desc):
|
|
||||||
kbs = cls.model.select().where(
|
|
||||||
((cls.model.tenant_id.in_(joined_tenant_ids) & (cls.model.permission ==
|
|
||||||
TenantPermission.TEAM.value)) | (cls.model.tenant_id == user_id))
|
|
||||||
& (cls.model.status == StatusEnum.VALID.value)
|
|
||||||
)
|
|
||||||
if desc:
|
|
||||||
kbs = kbs.order_by(cls.model.getter_by(orderby).desc())
|
|
||||||
else:
|
|
||||||
kbs = kbs.order_by(cls.model.getter_by(orderby).asc())
|
|
||||||
|
|
||||||
kbs = kbs.paginate(page_number, items_per_page)
|
|
||||||
|
|
||||||
return list(kbs.dicts())
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
@DB.connection_context()
|
|
||||||
def get_detail(cls, kb_id):
|
|
||||||
fields = [
|
|
||||||
cls.model.id,
|
|
||||||
Tenant.embd_id,
|
|
||||||
cls.model.avatar,
|
|
||||||
cls.model.name,
|
|
||||||
cls.model.description,
|
|
||||||
cls.model.permission,
|
|
||||||
cls.model.doc_num,
|
|
||||||
cls.model.token_num,
|
|
||||||
cls.model.chunk_num,
|
|
||||||
cls.model.parser_id]
|
|
||||||
kbs = cls.model.select(*fields).join(Tenant, on=((Tenant.id == cls.model.tenant_id)&(Tenant.status== StatusEnum.VALID.value))).where(
|
|
||||||
(cls.model.id == kb_id),
|
|
||||||
(cls.model.status == StatusEnum.VALID.value)
|
|
||||||
)
|
|
||||||
if not kbs:
|
|
||||||
return
|
|
||||||
d = kbs[0].to_dict()
|
|
||||||
d["embd_id"] = kbs[0].tenant.embd_id
|
|
||||||
return d
|
|
@ -14,17 +14,15 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from api.utils.file_utils import get_project_base_directory
|
from api.utils.file_utils import get_project_base_directory
|
||||||
|
|
||||||
|
|
||||||
def get_versions() -> typing.Mapping[str, typing.Any]:
|
def get_versions() -> typing.Mapping[str, typing.Any]:
|
||||||
return dotenv.dotenv_values(
|
dotenv.load_dotenv(dotenv.find_dotenv())
|
||||||
dotenv_path=os.path.join(get_project_base_directory(), "rag.env")
|
return dotenv.dotenv_values()
|
||||||
)
|
|
||||||
|
|
||||||
def get_rag_version() -> typing.Optional[str]:
|
def get_rag_version() -> typing.Optional[str]:
|
||||||
return get_versions().get("RAG")
|
return get_versions().get("RAGFLOW_VERSION", "dev")
|
Loading…
x
Reference in New Issue
Block a user