From 74624dd5c3efb9c38aa3140fb03f4f17d0a234b7 Mon Sep 17 00:00:00 2001 From: zlog <jon_yu@qq.com> Date: Fri, 15 Nov 2024 13:19:02 +0800 Subject: [PATCH] feat: Resolving UserWarning about llama-index-llms-dashscope (#16965) * feat: Resolving UserWarning about llama-index-llms-dashscope In Pydantic V2, protected_namespaces is a configuration option used to prevent certain namespace keywords (such as model_, etc.) from being used as field names. so we need to disable it here. * Update pyproject.toml update version to 0.2.6 * lint --------- Co-authored-by: Andrei Fajardo <andrei@nerdai.io> --- .../llama_index/llms/dashscope/base.py | 6 ++++++ .../llms/llama-index-llms-dashscope/pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/llama-index-integrations/llms/llama-index-llms-dashscope/llama_index/llms/dashscope/base.py b/llama-index-integrations/llms/llama-index-llms-dashscope/llama_index/llms/dashscope/base.py index fcc7e88b9..40c318cd8 100644 --- a/llama-index-integrations/llms/llama-index-llms-dashscope/llama_index/llms/dashscope/base.py +++ b/llama-index-integrations/llms/llama-index-llms-dashscope/llama_index/llms/dashscope/base.py @@ -2,6 +2,7 @@ from http import HTTPStatus from typing import Any, Dict, List, Optional, Sequence, Tuple +from pydantic import ConfigDict from llama_index.core.base.llms.types import ( ChatMessage, @@ -121,6 +122,11 @@ class DashScope(CustomLLM): ``` """ + """ In Pydantic V2, protected_namespaces is a configuration option used to prevent certain namespace keywords + (such as model_, etc.) from being used as field names. so we need to disable it here. + """ + model_config = ConfigDict(protected_namespaces=()) + model_name: str = Field( default=DashScopeGenerationModels.QWEN_MAX, description="The DashScope model to use.", diff --git a/llama-index-integrations/llms/llama-index-llms-dashscope/pyproject.toml b/llama-index-integrations/llms/llama-index-llms-dashscope/pyproject.toml index b81d41b09..3335d26a3 100644 --- a/llama-index-integrations/llms/llama-index-llms-dashscope/pyproject.toml +++ b/llama-index-integrations/llms/llama-index-llms-dashscope/pyproject.toml @@ -27,7 +27,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-llms-dashscope" readme = "README.md" -version = "0.2.5" +version = "0.2.6" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" -- GitLab