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

OpenAI API update #4

Open
rezkanas opened this issue Mar 29, 2024 · 3 comments
Open

OpenAI API update #4

rezkanas opened this issue Mar 29, 2024 · 3 comments

Comments

@rezkanas
Copy link

Hi
Thank you for your great work. I try to use your repo but so far run into problems when trying to reach openai servers.

Traceback (most recent call last):
  File "/home/anasrezklinux/anas_april/visual_story.py", line 1133, in <module>
    custom_diffusion_inference([character_1, character_2], step, lr)
  File "/home/anasrezklinux/anas_april/visual_story.py", line 512, in custom_diffusion_inference
    TIFA_metric_score, DALL_eval_score, ViTS_16_DINO_embeddings = score_images(image_path, real_photo_path_list, prompt)
  File "/home/anasrezklinux/anas_april/visual_story.py", line 53, in score_images
    return TIFA_metric_score(prompt, image_path),DALL_eval_score(prompt, image_path),[ViTS_16_DINO_embeddings(image_path, real_image_path) for real_image_path in real_image_paths]
  File "/home/anasrezklinux/anas_april/compile_story.py", line 86, in TIFA_metric_score
    gpt3_questions = get_question_and_answers(prompt)
  File "/home/anasrezklinux/anas_april/tifa/tifascore/question_gen.py", line 547, in get_question_and_answers
    resp = openai_completion(this_prompt)
  File "/home/anasrezklinux/anas_april/tifa/tifascore/openai_api.py", line 6, in openai_completion
    resp =  openai.ChatCompletion.create(
  File "/home/anasrezklinux/anas_april/venv/lib/python3.10/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.ChatCompletion, 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`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

for now I will revert to openai==0.28 , yet, it would be great if you could update this repo :)

@Yushi-Hu
Copy link
Owner

Hi!

Thanks for the reminder! I have updated the tifascore/openai_api.py and it should now works with latest openai pkg.

@rezkanas
Copy link
Author

thank you Yushi. please update it again to:
return resp.choices[0].message.content

@Yushi-Hu
Copy link
Owner

Thanks for pointing it out!

Sorry that I haven't checked this repo frequently and haven't tested it in the last commit. The code should work now.

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