mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
[partner]: minor change to embeddings for Ollama (#24521)
This commit is contained in:
parent
0f45ac4088
commit
464a525a5a
@ -14,7 +14,7 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
from langchain_ollama import OllamaEmbeddings
|
||||
|
||||
model = OllamaEmbeddings(model="llama3")
|
||||
embedder = OllamaEmbeddings(model="llama3")
|
||||
embedder.embed_query("what is the place that jonathan worked at?")
|
||||
"""
|
||||
|
||||
@ -28,9 +28,7 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||
"""Embed search docs."""
|
||||
embedded_docs = []
|
||||
for doc in texts:
|
||||
embedded_docs.append(list(ollama.embeddings(self.model, doc)["embedding"]))
|
||||
embedded_docs = ollama.embed(self.model, texts)["embeddings"]
|
||||
return embedded_docs
|
||||
|
||||
def embed_query(self, text: str) -> List[float]:
|
||||
@ -39,11 +37,7 @@ class OllamaEmbeddings(BaseModel, Embeddings):
|
||||
|
||||
async def aembed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||
"""Embed search docs."""
|
||||
embedded_docs = []
|
||||
for doc in texts:
|
||||
embedded_docs.append(
|
||||
list((await AsyncClient().embeddings(self.model, doc))["embedding"])
|
||||
)
|
||||
embedded_docs = (await AsyncClient().embed(self.model, texts))["embeddings"]
|
||||
return embedded_docs
|
||||
|
||||
async def aembed_query(self, text: str) -> List[float]:
|
||||
|
Loading…
Reference in New Issue
Block a user