Repository: mlflow/mlflow

Issue:
[BUG] Deployments Server import warning: "UserWarning: Valid config keys have changed in V2"
### Issues Policy acknowledgement

- [X] I have read and agree to submit bug reports in accordance with the [issues policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)

### Where did you encounter this bug?

Local machine

### Willingness to contribute

Yes. I can contribute a fix for this bug independently.

### MLflow version

- mlflow==2.11.1


### System information

- **OS Platform and Distribution**: Linux Ubuntu 24.04
- **Python version**: 3.11.8


### Describe the problem

Starting a deployments server (or really using any code that is importing from `mlflow.gateway.schemas.embeddings`) issues a pydantic deprecation warning when using pydantic V2:

```
.../python3.11/site-packages/pydantic/_internal/_config.py:322: UserWarning: Valid config keys have changed in V2:
* 'schema_extra' has been renamed to 'json_schema_extra'
  warnings.warn(message, UserWarning)
```

All pydantic models seem to have been made v2-compatible using `mlflow.gateway.config.IS_PYDANTIC_V2` with the exception of the `mlflow.gateway.schemas.embeddings.ResponsePayload` class.



### Tracking information

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```shell
REPLACE_ME
```


### Code to reproduce issue

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```
$ python --version                                    
Python 3.11.8

$ pip freeze | grep -e mlflow -e pydantic             
mlflow==2.11.1
pydantic==2.6.4
pydantic_core==2.16.3

$ python -c 'import mlflow.gateway.schemas.embeddings'
/workspaces/hub/.venv/lib/python3.11/site-packages/pydantic/_internal/_config.py:322: UserWarning: Valid config keys have changed in V2:
* 'schema_extra' has been renamed to 'json_schema_extra'
  warnings.warn(message, UserWarning)
```


### Stack trace

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```
REPLACE_ME
```


### Other info / logs

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```
REPLACE_ME
```


### What component(s) does this bug affect?

- [ ] `area/artifacts`: Artifact stores and artifact logging
- [ ] `area/build`: Build and test infrastructure for MLflow
- [X] `area/deployments`: MLflow Deployments client APIs, server, and third-party Deployments integrations
- [ ] `area/docs`: MLflow documentation pages
- [ ] `area/examples`: Example code
- [ ] `area/model-registry`: Model Registry service, APIs, and the fluent client calls for Model Registry
- [ ] `area/models`: MLmodel format, model serialization/deserialization, flavors
- [ ] `area/recipes`: Recipes, Recipe APIs, Recipe configs, Recipe Templates
- [ ] `area/projects`: MLproject format, project running backends
- [ ] `area/scoring`: MLflow Model server, model deployment tools, Spark UDFs
- [ ] `area/server-infra`: MLflow Tracking server backend
- [ ] `area/tracking`: Tracking Service, tracking client APIs, autologging

### What interface(s) does this bug affect?

- [ ] `area/uiux`: Front-end, user experience, plotting, JavaScript, JavaScript dev server
- [ ] `area/docker`: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
- [ ] `area/sqlalchemy`: Use of SQLAlchemy in the Tracking Service or Model Registry
- [ ] `area/windows`: Windows support

### What language(s) does this bug affect?

- [ ] `language/r`: R APIs and clients
- [ ] `language/java`: Java APIs and clients
- [ ] `language/new`: Proposals for new client languages

### What integration(s) does this bug affect?

- [ ] `integrations/azure`: Azure and Azure ML integrations
- [ ] `integrations/sagemaker`: SageMaker integrations
- [ ] `integrations/databricks`: Databricks integrations


Discussion:

Resolving patch:
diff --git a/mlflow/gateway/schemas/embeddings.py b/mlflow/gateway/schemas/embeddings.py
--- a/mlflow/gateway/schemas/embeddings.py
+++ b/mlflow/gateway/schemas/embeddings.py
@@ -31,6 +31,59 @@ class EmbeddingsUsage(ResponseModel):
     total_tokens: Optional[int] = None
 
 
+_RESPONSE_PAYLOAD_EXTRA_SCHEMA = {
+    "object": "list",
+    "data": [
+        {
+            "object": "embedding",
+            "index": 0,
+            "embedding": [
+                0.017291732,
+                -0.017291732,
+                0.014577783,
+                -0.02902633,
+                -0.037271563,
+                0.019333655,
+                -0.023055641,
+                -0.007359971,
+                -0.015818445,
+                -0.030654699,
+                0.008348623,
+                0.018312693,
+                -0.017149571,
+                -0.0044424757,
+                -0.011165961,
+                0.01018377,
+            ],
+        },
+        {
+            "object": "embedding",
+            "index": 1,
+            "embedding": [
+                0.0060126893,
+                -0.008691099,
+                -0.0040095365,
+                0.019889368,
+                0.036211833,
+                -0.0013270887,
+                0.013401738,
+                -0.0036735237,
+                -0.0049594184,
+                0.035229642,
+                -0.03435084,
+                0.019798903,
+                -0.0006110424,
+                0.0073793563,
+                0.005657291,
+                0.022487005,
+            ],
+        },
+    ],
+    "model": "text-embedding-ada-002-v2",
+    "usage": {"prompt_tokens": 400, "total_tokens": 400},
+}
+
+
 class ResponsePayload(ResponseModel):
     object: Literal["list"] = "list"
     data: List[EmbeddingObject]
@@ -38,54 +91,7 @@ class ResponsePayload(ResponseModel):
     usage: EmbeddingsUsage
 
     class Config:
-        schema_extra = {
-            "object": "list",
-            "data": [
-                {
-                    "object": "embedding",
-                    "index": 0,
-                    "embedding": [
-                        0.017291732,
-                        -0.017291732,
-                        0.014577783,
-                        -0.02902633,
-                        -0.037271563,
-                        0.019333655,
-                        -0.023055641,
-                        -0.007359971,
-                        -0.015818445,
-                        -0.030654699,
-                        0.008348623,
-                        0.018312693,
-                        -0.017149571,
-                        -0.0044424757,
-                        -0.011165961,
-                        0.01018377,
-                    ],
-                },
-                {
-                    "object": "embedding",
-                    "index": 1,
-                    "embedding": [
-                        0.0060126893,
-                        -0.008691099,
-                        -0.0040095365,
-                        0.019889368,
-                        0.036211833,
-                        -0.0013270887,
-                        0.013401738,
-                        -0.0036735237,
-                        -0.0049594184,
-                        0.035229642,
-                        -0.03435084,
-                        0.019798903,
-                        -0.0006110424,
-                        0.0073793563,
-                        0.005657291,
-                        0.022487005,
-                    ],
-                },
-            ],
-            "model": "text-embedding-ada-002-v2",
-            "usage": {"prompt_tokens": 400, "total_tokens": 400},
-        }
+        if IS_PYDANTIC_V2:
+            json_schema_extra = _RESPONSE_PAYLOAD_EXTRA_SCHEMA
+        else:
+            schema_extra = _RESPONSE_PAYLOAD_EXTRA_SCHEMA


Test patch: