Compare commits

...

4 Commits

Author SHA1 Message Date
isaac hershenson
0ecbe70b37 fixing image issues 2024-07-24 10:06:28 -07:00
isaac hershenson
984762c721 fmt 2024-07-23 16:58:49 -07:00
isaac hershenson
05fbb43ef6 typo 2024-07-22 16:13:50 -07:00
isaac hershenson
57de61a5ee batch embeddings 2024-07-22 14:19:01 -07:00
2 changed files with 4 additions and 10 deletions

View File

@@ -387,7 +387,7 @@ class ChatOllama(BaseChatModel):
elif (
isinstance(temp_image_url, dict) and "url" in temp_image_url
):
image_url = temp_image_url
image_url = temp_image_url['url']
else:
raise ValueError(
"Only string image_url or dict with string 'url' "

View File

@@ -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]: