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

TypeError using Ollama embedding models #7451

Open
tsmdt opened this issue Dec 28, 2024 · 0 comments
Open

TypeError using Ollama embedding models #7451

tsmdt opened this issue Dec 28, 2024 · 0 comments

Comments

@tsmdt
Copy link

tsmdt commented Dec 28, 2024

After upgrading from 1.54.1 to 1.56.3 I am getting a TypeError: object dict can't be used in 'await' expression whenever I try to embed strings using Ollama. I tested OpenAI (text-embedding-3-small) which works fine, but the following example code errors out with Ollama:

import litellm

text = 'Research Data Charta'

response = litellm.embedding(input=text, model='ollama/nomic-embed-text:latest')

print(response)

Error:

Traceback (most recent call last):
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/main.py", line 3670, in embedding
    response = ollama_embeddings_fn(  # type: ignore
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/llms/ollama/completion/handler.py", line 92, in ollama_embeddings
    return asyncio.run(
           ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/llms/ollama/completion/handler.py", line 55, in ollama_aembeddings
    response_json = await response.json()
                    ^^^^^^^^^^^^^^^^^^^^^
TypeError: object dict can't be used in 'await' expression

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/thomas/Code/projects/dygest/embedtest.py", line 5, in <module>
    response = litellm.embedding(input=text, model='ollama/nomic-embed-text:latest')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/utils.py", line 993, in wrapper
    raise e
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/utils.py", line 874, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/main.py", line 3829, in embedding
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2190, in exception_type
    raise e
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2166, in exception_type
    raise APIConnectionError(
litellm.exceptions.APIConnectionError: litellm.APIConnectionError: object dict can't be used in 'await' expression
Traceback (most recent call last):
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/main.py", line 3670, in embedding
    response = ollama_embeddings_fn(  # type: ignore
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/llms/ollama/completion/handler.py", line 92, in ollama_embeddings
    return asyncio.run(
           ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.8/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/thomas/Code/projects/dygest/venv_dygest/lib/python3.12/site-packages/litellm/llms/ollama/completion/handler.py", line 55, in ollama_aembeddings
    response_json = await response.json()
                    ^^^^^^^^^^^^^^^^^^^^^
TypeError: object dict can't be used in 'await' expression

Any help would be appreciated, thanks!

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

1 participant