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

AttributeError: module 'giskard.llm' has no attribute 'embeddings' #2076

Open
AmineDjeghri opened this issue Nov 18, 2024 · 3 comments
Open

Comments

@AmineDjeghri
Copy link

Issue Type

Bug

Source

source

Giskard Library Version

2.15.5

OS Platform and Distribution

Macos 14

Python version

3.11

Installed python packages

No response

Current Behaviour?

giskard.llm.embeddings.openai.set_embedding_model('text-embedding-ada-002')
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'giskard.llm' has no attribute 'embeddings'

Standalone code OR list down the steps to reproduce the issue

import openai
import pandas as pd
import tiktoken
from scipy import spatial

from giskard import scan, Dataset, Model

giskard.llm.set_llm_model('gpt-4o-mini')
giskard.llm.embeddings.openai.set_embedding_model('text-embedding-ada-002')

Relevant log output

No response

@AmineDjeghri
Copy link
Author

AmineDjeghri commented Nov 18, 2024

okey, apparently there is a PR that was merged 45min ago

#2074

edit : still doesn't work

@henchaves
Copy link
Member

Hey @AmineDjeghri !
Thanks for reporting this.

Could you try running this code:

from giskard.llm.embeddings.openai import set_embedding_model
set_embedding_model('text-embedding-ada-002')

for an unknown reason, it seems that giskard.llm.embeddings.openai.set_embedding_model is not working directly. I'll investigate further to see the cause of this. In the meanwhile, the previous code snippet should work.

@AmineDjeghri
Copy link
Author

Hey
thanks it works

Do you know if the doc is deprecated ?
https://docs.giskard.ai/en/latest/reference/notebooks/LLM_QA_Winter_Olympics.html

i found this code and it seems that it doesn't work :

    query_embedding_response = openai.Embedding.create(model=EMBEDDING_MODEL, input=query)
    query_embedding = query_embedding_response["data"][0]["embedding"]
Traceback (most recent call last):
  File "/Users/aminedjeghri/PycharmProjects/ai-cloud-project-template/temp.py", line 102, in <module>
    ask('Which athletes won the gold medal in curling at the 2022 Winter Olympics?')
  File "/Users/aminedjeghri/PycharmProjects/ai-cloud-project-template/temp.py", line 83, in ask
    message = query_message(query, db, model=model, token_budget=token_budget)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aminedjeghri/PycharmProjects/ai-cloud-project-template/temp.py", line 63, in query_message
    strings, _ = strings_ranked_by_relation(query, db)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aminedjeghri/PycharmProjects/ai-cloud-project-template/temp.py", line 40, in strings_ranked_by_relation
    query_embedding_response = openai.Embedding.create(model=EMBEDDING_MODEL, input=query)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aminedjeghri/PycharmProjects/ai-cloud-project-template/.venv/lib/python3.11/site-packages/openai/lib/_old_api.py", line 39, in __call__
    raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1: 

You tried to access openai.Embedding, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants