The `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead in class `SecretStr`.

我在windows环境下运行python main.py dev celery的时候出现了下面的错误,我想问下怎么解决的呢

(venv) PS E:\MaxKB-main> python main.py dev celery
Building prefix dict from the default dictionary …
DEBUG:jieba:Building prefix dict from the default dictionary …
Loading model from cache C:\Users\yy\AppData\Local\Temp\jieba.cache
DEBUG:jieba:Loading model from cache C:\Users\yy\AppData\Local\Temp\jieba.cache
Loading model cost 0.395 seconds.
DEBUG:jieba:Loading model cost 0.395 seconds.
Prefix dict has been built successfully.
DEBUG:jieba:Prefix dict has been built successfully.
Operations to perform:
Apply all migrations: application, contenttypes, dataset, django_apscheduler, django_celery_beat, embedding, function_lib, setting, users
Running migrations:
No migrations to apply.
Your models in app(s): ‘dataset’, ‘function_lib’ have changes that are not yet reflected in a migration, and so won’t be applied.
Run ‘manage.py makemigrations’ to make new migrations, and then re-run ‘manage.py migrate’ to apply them.
E:\MaxKB-main\apps\setting\models_provider\impl\ollama_model_provider\credential\embedding.py:15: LangChainDeprecationWarning: As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly.

For example, replace imports like: from langchain_core.pydantic_v1 import BaseModel
with: from pydantic import BaseModel
or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to pydantic 2 yet. from pydantic.v1 import BaseModel

from setting.models_provider.impl.local_model_provider.model.embedding import LocalEmbedding
E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_config.py:345: UserWarning: Valid config keys have changed in V2:

  • ‘allow_population_by_field_name’ has been renamed to ‘populate_by_name’
    warnings.warn(message, UserWarning)
    Traceback (most recent call last):
    File “”, line 198, in run_module_as_main
    File “”, line 88, in run_code
    File "E:\MaxKB-main\venv\Scripts\celery.exe_main
    .py", line 7, in
    File "E:\MaxKB-main\venv\Lib\site-packages\celery_main
    .py", line 15, in main
    sys.exit(_main())
    ^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\bin\celery.py”, line 236, in main
    return celery(auto_envvar_prefix=“CELERY”)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\core.py”, line 1157, in call
    return self.main(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\core.py”, line 1078, in main
    rv = self.invoke(ctx)
    ^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\core.py”, line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\core.py”, line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\core.py”, line 783, in invoke
    return _callback(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\click\decorators.py”, line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\bin\base.py”, line 135, in caller
    return f(ctx, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\bin\worker.py”, line 348, in worker
    worker = app.Worker(
    ^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\worker\worker.py”, line 93, in init
    self.app.loader.init_worker()
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\loaders\base.py”, line 110, in init_worker
    self.import_default_modules()
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\loaders\base.py”, line 104, in import_default_modules
    raise response
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\utils\dispatch\signal.py”, line 276, in send
    response = receiver(signal=self, sender=sender, **named)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\fixups\django.py”, line 100, in on_import_modules
    self.worker_fixup.validate_models()
    File “E:\MaxKB-main\venv\Lib\site-packages\celery\fixups\django.py”, line 140, in validate_models
    run_checks()
    File “E:\MaxKB-main\venv\Lib\site-packages\django\core\checks\registry.py”, line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\core\checks\urls.py”, line 16, in check_url_config
    return check_resolver(resolver)
    ^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\core\checks\urls.py”, line 26, in check_resolver
    return check_method()
    ^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\urls\resolvers.py”, line 531, in check
    for pattern in self.url_patterns:
    ^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\utils\functional.py”, line 47, in get
    res = instance.dict[self.name] = self.func(instance)
    ^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\urls\resolvers.py”, line 718, in url_patterns
    patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
    ^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\utils\functional.py”, line 47, in get
    res = instance.dict[self.name] = self.func(instance)
    ^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\django\urls\resolvers.py”, line 711, in urlconf_module
    return import_module(self.urlconf_name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\importlib_init
    .py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “”, line 1206, in gcd_import
    File “”, line 1178, in find_and_load
    File “”, line 1149, in find_and_load_unlocked
    File “”, line 690, in load_unlocked
    File “”, line 940, in exec_module
    File “”, line 241, in call_with_frames_removed
    File “E:\MaxKB-main\apps\smartdoc\urls.py”, line 24, in
    from application.urls import urlpatterns as application_urlpatterns
    File “E:\MaxKB-main\apps\application\urls.py”, line 3, in
    from . import views
    File "E:\MaxKB-main\apps\application\views_init
    .py", line 9, in
    from .application_views import *
    File “E:\MaxKB-main\apps\application\views\application_views.py”, line 18, in
    from application.serializers.application_serializers import ApplicationSerializer
    File “E:\MaxKB-main\apps\application\serializers\application_serializers.py”, line 27, in
    from application.flow.workflow_manage import Flow
    File “E:\MaxKB-main\apps\application\flow\workflow_manage.py”, line 23, in
    from application.flow.step_node import get_node
    File "E:\MaxKB-main\apps\application\flow\step_node_init
    .py", line 9, in
    from .ai_chat_step_node import *
    File "E:\MaxKB-main\apps\application\flow\step_node\ai_chat_step_node_init
    .py", line 9, in
    from .impl import *
    File "E:\MaxKB-main\apps\application\flow\step_node\ai_chat_step_node\impl_init
    .py", line 9, in
    from .base_chat_node import BaseChatNode
    File “E:\MaxKB-main\apps\application\flow\step_node\ai_chat_step_node\impl\base_chat_node.py”, line 20, in
    from setting.models_provider import get_model_credential
    File "E:\MaxKB-main\apps\setting\models_provider_init
    .py", line 13, in
    from setting.models_provider.constants.model_provider_constants import ModelProvideConstants
    File “E:\MaxKB-main\apps\setting\models_provider\constants\model_provider_constants.py”, line 21, in
    from setting.models_provider.impl.tencent_model_provider.tencent_model_provider import TencentModelProvider
    File “E:\MaxKB-main\apps\setting\models_provider\impl\tencent_model_provider\tencent_model_provider.py”, line 14, in
    from setting.models_provider.impl.tencent_model_provider.model.llm import TencentModel
    File “E:\MaxKB-main\apps\setting\models_provider\impl\tencent_model_provider\model\llm.py”, line 8, in
    from setting.models_provider.impl.tencent_model_provider.model.hunyuan import ChatHunyuan
    File “E:\MaxKB-main\apps\setting\models_provider\impl\tencent_model_provider\model\hunyuan.py”, line 85, in
    class ChatHunyuan(BaseChatModel):
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_model_construction.py”, line 226, in new
    complete_model_class(
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_model_construction.py”, line 658, in complete_model_class
    schema = cls.get_pydantic_core_schema(cls, handler)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic\main.py”, line 702, in get_pydantic_core_schema
    return handler(source)
    ^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_schema_generation_shared.py”, line 84, in call
    schema = self._handler(source_type)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 612, in generate_schema
    schema = self._generate_schema_inner(obj)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 881, in _generate_schema_inner
    return self._model_schema(obj)
    ^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 693, in _model_schema
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 693, in
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 1073, in _generate_md_field_schema
    common_field = self._common_field_schema(name, field_info, decorators)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 1265, in _common_field_schema
    schema = self._apply_annotations(
    ^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 2062, in _apply_annotations
    schema = get_inner_schema(source_type)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_schema_generation_shared.py”, line 84, in call
    schema = self._handler(source_type)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 2043, in inner_handler
    schema = self._generate_schema_inner(obj)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 886, in _generate_schema_inner
    return self.match_type(obj)
    ^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 988, in match_type
    return self._match_generic_type(obj, origin)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 1016, in _match_generic_type
    return self._union_schema(obj)
    ^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 1327, in _union_schema
    choices.append(self.generate_schema(arg))
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 614, in generate_schema
    metadata_js_function = _extract_get_pydantic_json_schema(obj, schema)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “E:\MaxKB-main\venv\Lib\site-packages\pydantic_internal_generate_schema.py”, line 2401, in _extract_get_pydantic_json_schema
    raise PydanticUserError(
    pydantic.errors.PydanticUserError: The __modify_schema__ method is not supported in Pydantic v2. Use __get_pydantic_json_schema__ instead in class SecretStr.

For further information visit Redirecting...

或者给出一下能够运行的三方库的版本号

Python版本是3.11.10,一般使用跟Python版本兼容的库版本即可。

现在是三方库之间不兼容,我使用pydantic2.10.3会报这个错pydantic.errors.PydanticUserError: The __modify_schema__ method is not supported in Pydantic v2. Use __get_pydantic_json_schema__ instead in class SecretStr.