-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed as not planned
Labels
questionFurther information is requestedFurther information is requested
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
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
2. In any file, try import openai.error
Alternatively, when I did this in terminal
pip install prompt2model
python prompt2model_demo.py
Code snippets
"""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}",
}
OS
Mac OS
Python version
Python v3.9
Library version
openai v1.3.0
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested