Skip to content

Commit 3ac510a

Browse files
committed
ruff
1 parent 87ab824 commit 3ac510a

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

libs/community/langchain_community/embeddings/localai.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,16 @@ async def _aembedding_func(self, text: str, *, engine: str) -> List[float]:
299299
# replace newlines, which can negatively affect performance.
300300
text = text.replace("\n", " ")
301301
return (
302-
await async_embed_with_retry(
303-
self,
304-
input=[text],
305-
**self._invocation_params,
302+
(
303+
await async_embed_with_retry(
304+
self,
305+
input=[text],
306+
**self._invocation_params,
307+
)
306308
)
307-
).data[0].embedding
309+
.data[0]
310+
.embedding
311+
)
308312

309313
def embed_documents(
310314
self, texts: List[str], chunk_size: Optional[int] = 0
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import pytest
32

43
from langchain_community.embeddings import LocalAIEmbeddings
@@ -7,20 +6,20 @@
76
@pytest.mark.requires("openai")
87
@pytest.mark.vcr
98
def test_localai_embed() -> None:
10-
llm=LocalAIEmbeddings(
11-
openai_api_key="foo", model="bge-m3",
12-
openai_api_base="https://foo.bar/v1")
13-
eqq=llm.embed_query("foo bar")
14-
assert len(eqq) > 100
15-
assert eqq[0] != eqq[1]
9+
llm = LocalAIEmbeddings(
10+
openai_api_key="foo", model="bge-m3", openai_api_base="https://foo.bar/v1"
11+
)
12+
eqq = llm.embed_query("foo bar")
13+
assert len(eqq) > 100
14+
assert eqq[0] != eqq[1]
1615

1716

1817
@pytest.mark.requires("openai")
1918
@pytest.mark.vcr
2019
async def test_localai_aembed() -> None:
21-
llm=LocalAIEmbeddings(
22-
openai_api_key="foo", model="bge-m3",
23-
openai_api_base="https://foo.bar/v1")
24-
eqq=await llm.aembed_query("foo bar")
25-
assert len(eqq) > 100
26-
assert eqq[0] != eqq[1]
20+
llm = LocalAIEmbeddings(
21+
openai_api_key="foo", model="bge-m3", openai_api_base="https://foo.bar/v1"
22+
)
23+
eqq = await llm.aembed_query("foo bar")
24+
assert len(eqq) > 100
25+
assert eqq[0] != eqq[1]

0 commit comments

Comments
 (0)