Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libs/community/langchain_community/embeddings/dashscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
dashscope_api_key: Optional[str] = None
max_retries: int = 5
"""Maximum number of retries to make when generating."""
dimension:Optional[int] = None
"""The number of dimension the resulting output embeddings should have.

Supported in `text-embedding-3` and 'text-embedding-v4' and later models.
"""

model_config = ConfigDict(
extra="forbid",
Expand Down Expand Up @@ -153,7 +158,7 @@
List of embeddings, one for each text.
"""
embeddings = embed_with_retry(
self, input=texts, text_type="document", model=self.model
self, input=texts, text_type="document", model=self.model,dimension=self.dimension

Check failure on line 161 in libs/community/langchain_community/embeddings/dashscope.py

View workflow job for this annotation

GitHub Actions / cd libs/community / Python 3.11

Ruff (E501)

langchain_community/embeddings/dashscope.py:161:89: E501 Line too long (94 > 88)
)
embedding_list = [item["embedding"] for item in embeddings]
return embedding_list
Expand All @@ -168,6 +173,6 @@
Embedding for the text.
"""
embedding = embed_with_retry(
self, input=text, text_type="query", model=self.model
self, input=text, text_type="query", model=self.model,dimension=self.dimension

Check failure on line 176 in libs/community/langchain_community/embeddings/dashscope.py

View workflow job for this annotation

GitHub Actions / cd libs/community / Python 3.11

Ruff (E501)

langchain_community/embeddings/dashscope.py:176:89: E501 Line too long (90 > 88)
)[0]["embedding"]
return embedding
Loading