Closed MarkJYC001 closed 7 months ago
I am using library prompt2model, and its demo shows that import openai.error
import openai.error
While then there is a Error ModuleNotFoundError: No module named 'openai.error'
ModuleNotFoundError: No module named 'openai.error'
My question is whether openai python have deleted the library openai.error? Is there any alternative code here?
I think there is a general problem of Module missing. Maybe try as following
1.In terminal, pip install openai
pip install openai
Alternatively, when I did this in terminal
pip install prompt2model
python prompt2model_demo.py
"""Tools for accessing API-based models.""" from __future__ import annotations # noqa FI58 import asyncio import json import logging import time import aiolimiter import litellm.utils import openai import openai.error import tiktoken from aiohttp import ClientSession from litellm import acompletion, completion from tqdm.asyncio import tqdm_asyncio # Note that litellm converts all API errors into openai errors, # so openai errors are valid even when using other services. API_ERRORS = ( openai.error.APIError, openai.error.Timeout, openai.error.RateLimitError, openai.error.ServiceUnavailableError, openai.error.InvalidRequestError, json.decoder.JSONDecodeError, AssertionError, ) ERROR_ERRORS_TO_MESSAGES = { openai.error.InvalidRequestError: "API Invalid Request: Prompt was filtered", openai.error.RateLimitError: "API rate limit exceeded. Sleeping for 10 seconds.", openai.error.APIConnectionError: "Error Communicating with API", openai.error.Timeout: "API Timeout Error: API Timeout", openai.error.ServiceUnavailableError: "API service unavailable error: {e}", openai.error.APIError: "API error: {e}", }
Mac OS
Python v3.9
openai v1.3.0
All exception classes are available from the top-level package, e.g. openai.BadRequestError.
openai.BadRequestError
your openai api version is too high, please use this code to install lower bersion api. pip3 install openai==0.28
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
I am using library prompt2model, and its demo shows that
import openai.error
While then there is a Error
ModuleNotFoundError: No module named 'openai.error'
My question is whether openai python have deleted the library openai.error? Is there any alternative code here?
To Reproduce
I think there is a general problem of Module missing. Maybe try as following
1.In terminal,
pip install openai
import openai.error
Alternatively, when I did this in terminal
pip install prompt2model
python prompt2model_demo.py
Code snippets
OS
Mac OS
Python version
Python v3.9
Library version
openai v1.3.0