Merge branch 'main' of https://github.com/maxkb-dev/maxkb
This commit is contained in:
commit
19ab61a1d4
@ -10,7 +10,8 @@ from typing import List, Dict
|
|||||||
from urllib.parse import urlparse, ParseResult
|
from urllib.parse import urlparse, ParseResult
|
||||||
|
|
||||||
from langchain_core.messages import BaseMessage, get_buffer_string
|
from langchain_core.messages import BaseMessage, get_buffer_string
|
||||||
from langchain_openai.chat_models import ChatOpenAI
|
from langchain_ollama.chat_models import ChatOllama
|
||||||
|
|
||||||
|
|
||||||
from common.config.tokenizer_manage_config import TokenizerManage
|
from common.config.tokenizer_manage_config import TokenizerManage
|
||||||
from setting.models_provider.base_model_provider import MaxKBBaseModel
|
from setting.models_provider.base_model_provider import MaxKBBaseModel
|
||||||
@ -24,7 +25,7 @@ def get_base_url(url: str):
|
|||||||
return result_url[:-1] if result_url.endswith("/") else result_url
|
return result_url[:-1] if result_url.endswith("/") else result_url
|
||||||
|
|
||||||
|
|
||||||
class OllamaChatModel(MaxKBBaseModel, ChatOpenAI):
|
class OllamaChatModel(MaxKBBaseModel, ChatOllama):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_cache_model():
|
def is_cache_model():
|
||||||
return False
|
return False
|
||||||
@ -33,12 +34,10 @@ class OllamaChatModel(MaxKBBaseModel, ChatOpenAI):
|
|||||||
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
|
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
|
||||||
api_base = model_credential.get('api_base', '')
|
api_base = model_credential.get('api_base', '')
|
||||||
base_url = get_base_url(api_base)
|
base_url = get_base_url(api_base)
|
||||||
base_url = base_url if base_url.endswith('/v1') else (base_url + '/v1')
|
|
||||||
optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs)
|
optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs)
|
||||||
|
|
||||||
return OllamaChatModel(model=model_name, openai_api_base=base_url,
|
return OllamaChatModel(model=model_name, base_url=base_url,
|
||||||
openai_api_key=model_credential.get('api_key'),
|
stream=True, **optional_params)
|
||||||
stream_usage=True, **optional_params)
|
|
||||||
|
|
||||||
def get_num_tokens_from_messages(self, messages: List[BaseMessage]) -> int:
|
def get_num_tokens_from_messages(self, messages: List[BaseMessage]) -> int:
|
||||||
tokenizer = TokenizerManage.get_tokenizer()
|
tokenizer = TokenizerManage.get_tokenizer()
|
||||||
|
|||||||
@ -28,6 +28,7 @@ pycryptodome = "^3.19.0"
|
|||||||
beautifulsoup4 = "^4.12.2"
|
beautifulsoup4 = "^4.12.2"
|
||||||
html2text = "^2024.2.26"
|
html2text = "^2024.2.26"
|
||||||
langchain-openai = "^0.1.8"
|
langchain-openai = "^0.1.8"
|
||||||
|
langchain-ollama = "0.1.3"
|
||||||
django-ipware = "^6.0.4"
|
django-ipware = "^6.0.4"
|
||||||
django-apscheduler = "^0.6.2"
|
django-apscheduler = "^0.6.2"
|
||||||
pymupdf = "1.24.9"
|
pymupdf = "1.24.9"
|
||||||
|
|||||||
@ -244,6 +244,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item.answer"
|
:modelValue="item.answer"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</div>
|
</div>
|
||||||
@ -264,6 +265,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item.answer"
|
:modelValue="item.answer"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
@ -300,6 +302,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="file_content"
|
:modelValue="file_content"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -351,6 +354,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="file_content"
|
:modelValue="file_content"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -374,6 +378,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item.content"
|
:modelValue="item.content"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -573,6 +578,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item.answer"
|
:modelValue="item.answer"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</div>
|
</div>
|
||||||
@ -603,6 +609,7 @@
|
|||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item.answer"
|
:modelValue="item.answer"
|
||||||
style="background: none"
|
style="background: none"
|
||||||
|
noImgZoomIn
|
||||||
/>
|
/>
|
||||||
<template v-else> -</template>
|
<template v-else> -</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -64,12 +64,7 @@
|
|||||||
:storeKey="storeKey"
|
:storeKey="storeKey"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
||||||
<el-table-column
|
<el-table-column prop="name" :label="$t('views.document.table.name')" min-width="280">
|
||||||
prop="name"
|
|
||||||
:label="$t('views.document.table.name')"
|
|
||||||
min-width="280"
|
|
||||||
sortable
|
|
||||||
>
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<ReadWrite
|
<ReadWrite
|
||||||
@change="editName($event, row.id)"
|
@change="editName($event, row.id)"
|
||||||
@ -250,12 +245,7 @@
|
|||||||
{{ $t(hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod]) }}
|
{{ $t(hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod]) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column prop="create_time" :label="$t('common.createTime')" width="175" sortable>
|
||||||
prop="create_time"
|
|
||||||
:label="$t('common.createTime')"
|
|
||||||
width="175"
|
|
||||||
sortable
|
|
||||||
>
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ datetimeFormat(row.create_time) }}
|
{{ datetimeFormat(row.create_time) }}
|
||||||
</template>
|
</template>
|
||||||
@ -829,7 +819,7 @@ function getList(bool?: boolean) {
|
|||||||
const param = {
|
const param = {
|
||||||
...(filterText.value && { name: filterText.value }),
|
...(filterText.value && { name: filterText.value }),
|
||||||
...filterMethod.value,
|
...filterMethod.value,
|
||||||
order_by: orderBy.value,
|
order_by: orderBy.value
|
||||||
}
|
}
|
||||||
documentApi
|
documentApi
|
||||||
.getDocument(id as string, paginationConfig.value, param, bool ? undefined : loading)
|
.getDocument(id as string, paginationConfig.value, param, bool ? undefined : loading)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user