mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
refactor: remove print.
This commit is contained in:
parent
18b40f3664
commit
8c0836627a
|
|
@ -37,7 +37,6 @@ class BaseTextToVideoNode(ITextToVideoNode):
|
|||
self.context['dialogue_type'] = dialogue_type
|
||||
self.context['negative_prompt'] = self.generate_prompt_question(negative_prompt)
|
||||
video_urls = ttv_model.generate_video(question, negative_prompt)
|
||||
print('video_urls', video_urls)
|
||||
# 保存图片
|
||||
if video_urls is None:
|
||||
return NodeResult({'answer': gettext('Failed to generate video')}, {})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
import concurrent
|
||||
import json
|
||||
import threading
|
||||
import traceback
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from functools import reduce
|
||||
from typing import List, Dict
|
||||
|
|
@ -26,6 +25,7 @@ from application.flow.i_step_node import INode, WorkFlowPostHandler, NodeResult
|
|||
from application.flow.step_node import get_node
|
||||
from common.handle.base_to_response import BaseToResponse
|
||||
from common.handle.impl.response.system_to_response import SystemToResponse
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=200)
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ class WorkflowManage:
|
|||
current_node, node_result_future)
|
||||
return result
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
return None
|
||||
|
||||
def hand_node_result(self, current_node, node_result_future):
|
||||
|
|
@ -395,7 +395,7 @@ class WorkflowManage:
|
|||
list(result)
|
||||
return current_result
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
self.status = 500
|
||||
current_node.get_write_error_context(e)
|
||||
self.answer += str(e)
|
||||
|
|
@ -473,7 +473,7 @@ class WorkflowManage:
|
|||
return current_result
|
||||
except Exception as e:
|
||||
# 添加节点
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'],
|
||||
self.params['chat_record_id'],
|
||||
current_node.id,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2023/9/4 11:16
|
||||
@desc: 认证类
|
||||
"""
|
||||
import traceback
|
||||
from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
|
|
@ -18,6 +17,7 @@ from rest_framework.authentication import TokenAuthentication
|
|||
|
||||
from common.exception.app_exception import AppAuthenticationFailed, AppEmbedIdentityFailed, AppChatNumOutOfBoundsFailed, \
|
||||
AppApiException
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
token_cache = cache.caches['default']
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class TokenAuth(TokenAuthentication):
|
|||
return handle.handle(request, token, token_details.get_token_details)
|
||||
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect! illegal user'))
|
||||
except Exception as e:
|
||||
traceback.print_stack()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppEmbedIdentityFailed) or isinstance(e, AppChatNumOutOfBoundsFailed) or isinstance(e,
|
||||
AppApiException):
|
||||
raise e
|
||||
|
|
|
|||
|
|
@ -77,5 +77,5 @@ class HTMLSplitHandle(BaseSplitHandle):
|
|||
content = buffer.decode(encoding)
|
||||
return html2text(content)
|
||||
except BaseException as e:
|
||||
traceback.print_exception(e)
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
return f'{e}'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
@desc:
|
||||
"""
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
from typing import List
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from common import forms
|
||||
|
|
@ -7,7 +6,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AliyunBaiLianAsrSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
api_url = forms.TextInputField(_('API URL'), required=True)
|
||||
|
|
@ -41,7 +40,7 @@ class AliyunBaiLianAsrSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/10/16 17:01
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -16,6 +15,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.aliyun_bai_lian_model_provider.model.embedding import AliyunBaiLianEmbedding
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class BaiLianEmbeddingModelParams(BaseForm):
|
||||
dimensions = forms.SingleSelect(
|
||||
|
|
@ -69,7 +69,7 @@ class AliyunBaiLianEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model: AliyunBaiLianEmbedding = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_("Hello"))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
|
|
@ -69,7 +67,7 @@ class QwenVLModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth(model_credential.get('api_key'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -9,7 +8,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
|
||||
from common.forms.switch_field import SwitchField
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class QwenModelParams(BaseForm):
|
||||
"""
|
||||
|
|
@ -85,7 +84,7 @@ class ImageToVideoModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -9,7 +8,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class BaiLianLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(
|
||||
|
|
@ -76,7 +75,7 @@ class BaiLianLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
else:
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from common import forms
|
||||
|
|
@ -7,6 +6,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, PasswordInputField, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext as _
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AliyunBaiLianOmiSTTModelParams(BaseForm):
|
||||
CueWord = forms.TextInputField(
|
||||
|
|
@ -49,7 +49,7 @@ class AliyunBaiLianOmiSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -10,7 +9,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, PasswordInputField
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.aliyun_bai_lian_model_provider.model.reranker import AliyunBaiLianReranker
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AliyunBaiLianRerankerCredential(BaseForm, BaseModelCredential):
|
||||
"""
|
||||
|
|
@ -60,7 +59,7 @@ class AliyunBaiLianRerankerCredential(BaseForm, BaseModelCredential):
|
|||
model: AliyunBaiLianReranker = provider.get_model(model_type, model_name, model_credential)
|
||||
model.compress_documents([Document(page_content=_('Hello'))], _('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -9,7 +8,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, PasswordInputField, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AliyunBaiLianSTTModelParams(BaseForm):
|
||||
sample_rate = forms.SliderField(
|
||||
|
|
@ -68,7 +67,7 @@ class AliyunBaiLianSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential,**model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from django.utils.translation import gettext_lazy as _, gettext
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class QwenModelParams(BaseForm):
|
||||
"""
|
||||
|
|
@ -110,7 +109,7 @@ class QwenTextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from django.utils.translation import gettext_lazy as _, gettext
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AliyunBaiLianTTSModelGeneralParams(BaseForm):
|
||||
"""
|
||||
|
|
@ -103,7 +102,7 @@ class AliyunBaiLianTTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict, Any
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -9,7 +8,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
|
||||
from common.forms.switch_field import SwitchField
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class QwenModelParams(BaseForm):
|
||||
"""
|
||||
|
|
@ -87,7 +86,7 @@ class TextToVideoModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ class AliyunBaiLianSpeechToText(MaxKBBaseModel, BaseSpeechToText):
|
|||
'callback': None,
|
||||
**self.params
|
||||
}
|
||||
print(recognition_params)
|
||||
recognition = Recognition(**recognition_params)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -54,7 +53,7 @@ class AnthropicImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -16,7 +15,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AnthropicLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -56,7 +55,7 @@ class AnthropicLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.aws_bedrock_model_provider.model.embedding import BedrockEmbeddingModel
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class BedrockEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ class BedrockEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
except AppApiException:
|
||||
raise
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
_('Verification failed, please check whether the parameters are correct: {error}').format(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import ValidCode, BaseModelCredential
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class BedrockLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -54,7 +53,7 @@ class BedrockLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
except AppApiException:
|
||||
raise
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 17:08
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AzureOpenAIEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ class AzureOpenAIEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -57,7 +56,7 @@ class AzureOpenAIImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 17:08
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -17,7 +16,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AzureLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -68,7 +67,7 @@ class AzureLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException) or isinstance(e, BadRequestError):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AzureOpenAISTTModelCredential(BaseForm, BaseModelCredential):
|
||||
api_version = forms.TextInputField("API Version", required=True)
|
||||
|
|
@ -32,7 +31,7 @@ class AzureOpenAISTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AzureOpenAITTIModelParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -67,7 +66,7 @@ class AzureOpenAITextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class AzureOpenAITTSModelGeneralParams(BaseForm):
|
||||
# alloy, echo, fable, onyx, nova, shimmer
|
||||
|
|
@ -50,7 +49,7 @@ class AzureOpenAITTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 17:51
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class DeepSeekLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -56,7 +55,7 @@ class DeepSeekLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class GeminiEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
|
||||
|
|
@ -35,7 +34,7 @@ class GeminiEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -53,7 +52,7 @@ class GeminiImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 17:57
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class GeminiLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -56,7 +55,7 @@ class GeminiLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class GeminiSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
api_key = forms.PasswordInputField('API Key', required=True)
|
||||
|
|
@ -30,7 +29,7 @@ class GeminiSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:06
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class KimiLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -56,7 +55,7 @@ class KimiLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2025/11/7 14:02
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.local_model_provider.model.embedding import LocalEmbedding
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class LocalEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ class LocalEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model: LocalEmbedding = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(gettext('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2025/11/7 14:23
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
|
@ -17,7 +16,7 @@ from common.forms import BaseForm
|
|||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.local_model_provider.model.reranker import LocalReranker
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class LocalRerankerCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ class LocalRerankerCredential(BaseForm, BaseModelCredential):
|
|||
model: LocalReranker = provider.get_model(model_type, model_name, model_credential)
|
||||
model.compress_documents([Document(page_content=gettext('Hello'))], gettext('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class LocalReranker(MaxKBBaseModel, BaseModel, BaseDocumentCompressor):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
print('ssss', kwargs.get('model_id', None))
|
||||
self.model_id = kwargs.get('model_id', None)
|
||||
|
||||
def compress_documents(self, documents: Sequence[Document], query: str, callbacks: Optional[Callbacks] = None) -> \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,6 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class OpenAIEmbeddingModelParams(BaseForm):
|
||||
dimensions = forms.SingleSelect(
|
||||
|
|
@ -53,7 +53,7 @@ class OpenAIEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -56,7 +55,7 @@ class OpenAIImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -17,7 +16,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class OpenAILLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -58,7 +57,7 @@ class OpenAILLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException) or isinstance(e, BadRequestError):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class OpenAISTTModelParams(BaseForm):
|
||||
language = forms.TextInputField(
|
||||
|
|
@ -38,7 +37,7 @@ class OpenAISTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class OpenAITTIModelParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -70,7 +69,7 @@ class OpenAITextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class OpenAITTSModelGeneralParams(BaseForm):
|
||||
# alloy, echo, fable, onyx, nova, shimmer
|
||||
|
|
@ -49,7 +48,7 @@ class OpenAITTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class RegoloEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
|
||||
|
|
@ -35,7 +34,7 @@ class RegoloEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -12,7 +11,7 @@ from common.forms import BaseForm, TooltipLabel
|
|||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class RegoloImageModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -53,10 +52,8 @@ class RegoloImageModelCredential(BaseForm, BaseModelCredential):
|
|||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.stream([HumanMessage(content=[{"type": "text", "text": gettext('Hello')}])])
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class RegoloLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -57,7 +56,7 @@ class RegoloLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class RegoloTTIModelParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -68,9 +67,8 @@ class RegoloTextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
try:
|
||||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
|
||||
|
|
@ -35,7 +34,7 @@ class SiliconCloudEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -56,7 +55,7 @@ class SiliconCloudImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -57,7 +56,7 @@ class SiliconCloudLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/9/9 17:51
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -17,7 +16,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.siliconCloud_model_provider.model.reranker import SiliconCloudReranker
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudRerankerCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ class SiliconCloudRerankerCredential(BaseForm, BaseModelCredential):
|
|||
model: SiliconCloudReranker = provider.get_model(model_type, model_name, model_credential)
|
||||
model.compress_documents([Document(page_content=_('Hello'))], _('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
api_base = forms.TextInputField('API URL', required=True)
|
||||
|
|
@ -31,7 +30,7 @@ class SiliconCloudSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential,**model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudTTIModelParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -70,7 +69,7 @@ class SiliconCloudTextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,6 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class SiliconCloudTTSModelGeneralParams(BaseForm):
|
||||
# alloy, echo, fable, onyx, nova, shimmer
|
||||
|
|
@ -50,7 +50,7 @@ class SiliconCloudTTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class TencentCloudLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -57,7 +56,7 @@ class TencentCloudLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -7,7 +6,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class TencentEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ class TencentEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -58,7 +57,7 @@ class TencentVisionModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class TencentLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -50,7 +49,7 @@ class TencentLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import traceback
|
||||
|
||||
from common import forms
|
||||
from common.exception.app_exception import AppApiException
|
||||
|
|
@ -6,7 +5,7 @@ from common.forms import BaseForm, TooltipLabel
|
|||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class TencentSSTModelParams(BaseForm):
|
||||
EngSerViceType = forms.SingleSelect(
|
||||
|
|
@ -71,7 +70,7 @@ class TencentSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
|
|
@ -7,7 +6,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class TencentTTIModelParams(BaseForm):
|
||||
Style = forms.SingleSelect(
|
||||
|
|
@ -97,7 +96,7 @@ class TencentTTIModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VllmEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
|
||||
|
|
@ -35,7 +34,7 @@ class VllmEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -54,7 +53,7 @@ class VllmImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -9,7 +8,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -49,7 +48,7 @@ class VLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
try:
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
'Verification failed, please check whether the parameters are correct: {error}').format(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
|
@ -10,7 +9,7 @@ from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from models_provider.impl.vllm_model_provider.model.reranker import VllmBgeReranker
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VllmRerankerCredential(BaseForm, BaseModelCredential):
|
||||
api_url = forms.TextInputField('API URL', required=True)
|
||||
|
|
@ -34,7 +33,7 @@ class VllmRerankerCredential(BaseForm, BaseModelCredential):
|
|||
test_text = str(_('Hello'))
|
||||
model.compress_documents([Document(page_content=test_text)], test_text)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
|
||||
|
|
@ -35,7 +34,7 @@ class VolcanicEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -54,7 +53,7 @@ class VolcanicEngineImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/11 17:57
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEngineLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -56,7 +55,7 @@ class VolcanicEngineLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,6 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEngineSTTModelParams(BaseForm):
|
||||
uid = forms.TextInputField(
|
||||
|
|
@ -42,7 +42,7 @@ class VolcanicEngineSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEngineTTIModelGeneralParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -52,7 +51,7 @@ class VolcanicEngineTTIModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEngineTTSModelGeneralParams(BaseForm):
|
||||
voice_type = forms.SingleSelect(
|
||||
|
|
@ -60,7 +59,7 @@ class VolcanicEngineTTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -9,7 +8,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm, TooltipLabel, SingleSelect, TextInputField
|
||||
from common.forms.switch_field import SwitchField
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class VolcanicEngineTTVModelGeneralParams(BaseForm):
|
||||
resolution = SingleSelect(
|
||||
|
|
@ -72,7 +71,7 @@ class VolcanicEngineTTVModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/10/17 15:40
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class QianfanEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ class QianfanEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 10:19
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class WenxinLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -66,7 +65,7 @@ class WenxinLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model.invoke(
|
||||
[HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
raise e
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/10/17 15:40
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -15,7 +14,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class XFEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ class XFEmbeddingCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.embed_query(_('Hello'))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -12,7 +11,7 @@ from common.exception.app_exception import AppApiException
|
|||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
from models_provider.impl.xf_model_provider.model.image import ImageMessage
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class XunFeiImageModelCredential(BaseForm, BaseModelCredential):
|
||||
spark_api_url = forms.TextInputField('API URL', required=True,
|
||||
|
|
@ -42,7 +41,7 @@ class XunFeiImageModelCredential(BaseForm, BaseModelCredential):
|
|||
HumanMessage(_('Please outline this picture'))]
|
||||
model.stream(message_list)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 10:29
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class XunFeiLLMModelGeneralParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -75,7 +74,7 @@ class XunFeiLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class XunFeiSTTModelParams(BaseForm):
|
||||
language = forms.TextInputField(
|
||||
|
|
@ -51,7 +50,7 @@ class XunFeiSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class XunFeiTTSModelGeneralParams(BaseForm):
|
||||
vcn = forms.SingleSelect(
|
||||
|
|
@ -56,7 +55,7 @@ class XunFeiTTSModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
|
||||
class ZhEnXunFeiSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
|
|
@ -38,7 +37,7 @@ class ZhEnXunFeiSTTModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -53,7 +52,7 @@ class ZhiPuImageModelCredential(BaseForm, BaseModelCredential):
|
|||
for chunk in res:
|
||||
maxkb_logger.info(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
@date:2024/7/12 10:46
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -16,7 +15,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class ZhiPuLLMModelParams(BaseForm):
|
||||
temperature = forms.SliderField(TooltipLabel(_('Temperature'),
|
||||
|
|
@ -55,7 +54,7 @@ class ZhiPuLLMModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
|
@ -8,7 +7,7 @@ from common import forms
|
|||
from common.exception.app_exception import AppApiException
|
||||
from common.forms import BaseForm, TooltipLabel
|
||||
from models_provider.base_model_provider import BaseModelCredential, ValidCode
|
||||
|
||||
from common.utils.logger import maxkb_logger
|
||||
|
||||
class ZhiPuTTIModelParams(BaseForm):
|
||||
size = forms.SingleSelect(
|
||||
|
|
@ -49,7 +48,7 @@ class ZhiPuTextToImageModelCredential(BaseForm, BaseModelCredential):
|
|||
model = provider.get_model(model_type, model_name, model_credential, **model_params)
|
||||
res = model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
maxkb_logger.error(f'Exception: {e}', exc_info=True)
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
|
|
|||
Loading…
Reference in New Issue