fix: Model addition, error log printing (#2499)
This commit is contained in:
parent
83d51ea866
commit
ea9c5e0ee8
@ -6,6 +6,7 @@
|
||||
@date:2024/10/16 17:01
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -35,6 +36,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,7 @@ class QwenVLModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -48,6 +49,7 @@ class BaiLianLLMModelCredential(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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/9/9 17:51
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -35,6 +36,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -30,6 +30,7 @@ class AliyunBaiLianSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -76,6 +77,7 @@ class QwenTextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -64,6 +64,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -52,6 +53,7 @@ class AnthropicImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -55,6 +56,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -35,6 +36,7 @@ class BedrockEmbeddingCredential(BaseForm, BaseModelCredential):
|
||||
except AppApiException:
|
||||
raise
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
_('Verification failed, please check whether the parameters are correct: {error}').format(
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -53,6 +54,7 @@ class BedrockLLMModelCredential(BaseForm, BaseModelCredential):
|
||||
except AppApiException:
|
||||
raise
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 17:08
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -35,6 +36,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -55,6 +56,7 @@ class AzureOpenAIImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 17:08
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -55,6 +56,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -31,6 +32,7 @@ class AzureOpenAISTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -67,6 +68,7 @@ class AzureOpenAITextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -49,6 +50,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 17:51
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -55,6 +56,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -52,6 +52,7 @@ class GeminiImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 17:57
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,7 @@ class GeminiLLMModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -29,6 +30,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:06
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -55,6 +56,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 11:06
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/9/3 14:33
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.documents import Document
|
||||
@ -35,6 +36,7 @@ class LocalRerankerCredential(BaseForm, BaseModelCredential):
|
||||
model: LocalBaseReranker = 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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -54,6 +55,7 @@ class OpenAIImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -30,6 +31,7 @@ class OpenAISTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -70,6 +71,7 @@ class OpenAITextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -48,6 +49,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,7 @@ class QwenVLModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -54,6 +55,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -76,6 +77,7 @@ class QwenTextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
@ -54,6 +55,7 @@ class SiliconCloudImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/9/9 17:51
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -35,6 +36,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -30,6 +31,7 @@ class SiliconCloudSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -70,6 +71,7 @@ class SiliconCloudTextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -48,6 +49,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:32
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -21,6 +22,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 18:41
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,7 @@ class TencentVisionModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
||||
@ -48,6 +50,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()
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
|
||||
@ -96,6 +97,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()
|
||||
if raise_exception:
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -52,6 +53,7 @@ class VllmImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -49,6 +49,7 @@ class VLLMModelCredential(BaseForm, BaseModelCredential):
|
||||
try:
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
raise AppApiException(ValidCode.valid_error.value,
|
||||
gettext(
|
||||
'Verification failed, please check whether the parameters are correct: {error}').format(
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 16:45
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +35,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -52,6 +53,7 @@ class VolcanicEngineImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/11 17:57
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +57,7 @@ class VolcanicEngineLLMModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.invoke([HumanMessage(content=gettext('Hello'))])
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -34,6 +34,7 @@ class VolcanicEngineSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -50,6 +50,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -62,6 +62,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/10/17 15:40
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -29,6 +30,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 10:19
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -58,6 +59,7 @@ class WenxinLLMModelCredential(BaseForm, BaseModelCredential):
|
||||
model.invoke(
|
||||
[HumanMessage(content=gettext('Hello'))])
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
raise e
|
||||
return True
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/10/17 15:40
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -29,6 +30,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# coding=utf-8
|
||||
import base64
|
||||
import os
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -41,6 +42,7 @@ class XunFeiImageModelCredential(BaseForm, BaseModelCredential):
|
||||
HumanMessage(_('Please outline this picture'))]
|
||||
model.stream(message_list)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 10:29
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -74,6 +75,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
@ -33,6 +33,7 @@ class XunFeiSTTModelCredential(BaseForm, BaseModelCredential):
|
||||
model = provider.get_model(model_type, model_name, model_credential)
|
||||
model.check_auth()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# coding=utf-8
|
||||
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -56,6 +56,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -51,6 +52,7 @@ class ZhiPuImageModelCredential(BaseForm, BaseModelCredential):
|
||||
for chunk in res:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
@date:2024/7/12 10:46
|
||||
@desc:
|
||||
"""
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -54,6 +55,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()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import traceback
|
||||
from typing import Dict
|
||||
|
||||
from django.utils.translation import gettext_lazy as _, gettext
|
||||
@ -49,6 +50,7 @@ class ZhiPuTextToImageModelCredential(BaseForm, BaseModelCredential):
|
||||
res = model.check_auth()
|
||||
print(res)
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
if isinstance(e, AppApiException):
|
||||
raise e
|
||||
if raise_exception:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user