Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple script no longer works in 0.2.0 (ValueError: could not convert string to float: 'float_') #81

Closed
bovlb opened this issue Aug 2, 2024 · 1 comment

Comments

@bovlb
Copy link

bovlb commented Aug 2, 2024

from langchain_cohere import CohereEmbeddings
embeddings = CohereEmbeddings(model="embed-multilingual-v3.0")
emb = embeddings.embed_query("Hello, world!")

This script works in versions before 0.2.0. In 0.2.0 it produces the error:

ValueError: could not convert string to float: 'float_'
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], [line 4](vscode-notebook-cell:?execution_count=4&line=4)
      [1](vscode-notebook-cell:?execution_count=4&line=1) from langchain_cohere import CohereEmbeddings
      [2](vscode-notebook-cell:?execution_count=4&line=2) embeddings = CohereEmbeddings(model="embed-multilingual-v3.0")
----> [4](vscode-notebook-cell:?execution_count=4&line=4) emb = embeddings.embed_query("Hello, world!")

File ~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:193, in CohereEmbeddings.embed_query(self, text)
    [184](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:184) def embed_query(self, text: str) -> List[float]:
    [185](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:185)     """Call out to Cohere's embedding endpoint.
    [186](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:186) 
    [187](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:187)     Args:
   (...)
    [191](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:191)         Embeddings for the text.
    [192](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:192)     """
--> [193](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:193)     return self.embed([text], input_type="search_query")[0]

File ~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:143, in CohereEmbeddings.embed(self, texts, input_type)
    [130](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:130) def embed(
    [131](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:131)     self,
    [132](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:132)     texts: List[str],
    [133](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:133)     *,
    [134](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:134)     input_type: typing.Optional[cohere.EmbedInputType] = None,
    [135](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:135) ) -> List[List[float]]:
    [136](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:136)     embeddings = self.embed_with_retry(
    [137](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:137)         model=self.model,
    [138](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:138)         texts=texts,
   (...)
    [141](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:141)         embedding_types=self.embedding_types,
    [142](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:142)     ).embeddings
--> [143](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:143)     return [list(map(float, e)) for e in embeddings]

File ~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:143, in <listcomp>(.0)
    [130](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:130) def embed(
    [131](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:131)     self,
    [132](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:132)     texts: List[str],
    [133](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:133)     *,
    [134](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:134)     input_type: typing.Optional[cohere.EmbedInputType] = None,
    [135](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:135) ) -> List[List[float]]:
    [136](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:136)     embeddings = self.embed_with_retry(
    [137](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:137)         model=self.model,
    [138](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:138)         texts=texts,
   (...)
    [141](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:141)         embedding_types=self.embedding_types,
    [142](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:142)     ).embeddings
--> [143](https://vscode-remote+ssh-002dremote-002bthyme.vscode-resource.vscode-cdn.net/home/gavin/jupyter/~/.local/lib/python3.10/site-packages/langchain_cohere/embeddings.py:143)     return [list(map(float, e)) for e in embeddings]

ValueError: could not convert string to float: 'float_'
Anirudh31415926535 added a commit that referenced this issue Aug 12, 2024
Fixes: #61 and
#81

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: harry-cohere <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@Anirudh31415926535
Copy link
Collaborator

Hi @bovlb thanks for raising this issue! This is now fixed in 0.2.1 release! :)

isahers1 added a commit to langchain-ai/langchain that referenced this issue Aug 14, 2024
This can be finished after the following issue is resolved:

langchain-ai/langchain-cohere#81

Related to: #24856

```json
[
   {
      "provider": "cohere",
      "js":  true,
      "local": false,
     "serializable": false,
   }
]
```

---------

Co-authored-by: isaac hershenson <[email protected]>
Co-authored-by: Isaac Francisco <[email protected]>
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
…25250)

This can be finished after the following issue is resolved:

langchain-ai/langchain-cohere#81

Related to: langchain-ai#24856

```json
[
   {
      "provider": "cohere",
      "js":  true,
      "local": false,
     "serializable": false,
   }
]
```

---------

Co-authored-by: isaac hershenson <[email protected]>
Co-authored-by: Isaac Francisco <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants