huggingface[patch], pinecone[patch], fireworks[patch], mistralai[patch], voyageai[patch], togetherai[path]: convert Pydantic extras to literals (#25384)

Backwards compatible change that converts pydantic extras to literals
which is consistent with pydantic 2 usage.

- fireworks
- voyage ai
- mistralai
- mistral ai
- together ai
- huggigng face
- pinecone
This commit is contained in:
Eugene Yurtsev
2024-08-14 09:55:30 -04:00
committed by GitHub
parent d00176e523
commit 5f5e8c9a60
10 changed files with 15 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
from typing import Any, Dict, List, Optional # type: ignore[import-not-found]
from langchain_core.embeddings import Embeddings
from langchain_core.pydantic_v1 import BaseModel, Extra, Field
from langchain_core.pydantic_v1 import BaseModel, Field
DEFAULT_MODEL_NAME = "sentence-transformers/all-mpnet-base-v2"
@@ -65,7 +65,7 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings):
class Config:
"""Configuration for this pydantic object."""
extra = Extra.forbid
extra = "forbid"
def embed_documents(self, texts: List[str]) -> List[List[float]]:
"""Compute doc embeddings using a HuggingFace transformer model.