Skip to content

OpenAI == 0.28 or migrate the codebase to work with newer openai api? #1

Description

@aryopg

I'm getting an error that is related to an outdated code:

Traceback (most recent call last):
  File "/home/lean-hallucination/main.py", line 125, in <module>
    main()
  File "/home/lean-hallucination/main.py", line 92, in main
    results, accuracy = process_mmlu_pro_questions(math_dataset, output_file_path, formulation_prompt_path, openai)
  File "/home/lean-hallucination/data_preprocessing.py", line 289, in process_mmlu_pro_questions
    gpt_result = predict_gpt(openai, messages)
  File "/home/lean-hallucination/utils.py", line 45, in predict_gpt
    response = openai.ChatCompletion.create(
  File "/home/miniconda3/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

Should we update the utils.py or update the requirements.txt? I'd prefer updating the utils.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions