import os
from dotenv import load_dotenv
# API KEY 정보로드
load_dotenv()
import pandas as pd
from pandasai import SmartDataframe
print(os.environ['OPENAI_API_KEY'])
from pandasai.llm import OpenAI
llm = OpenAI(api_token = os.environ['OPENAI_API_KEY'])
sales_by_country = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"sales": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})
sales_by_country.head()
df = SmartDataframe(sales_by_country, config={"llm": llm})
df.chat('Which are the top 5 countries by sales?')
아래와 같이 오류가 발생
Traceback (most recent call last):
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\pipelines\chat\generate_chat_pipeline.py", line 335, in run
).run(input)
^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\pipelines\pipeline.py", line 137, in run
raise e
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\pipelines\pipeline.py", line 101, in run
step_output = logic.execute(
^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\pipelines\chat\code_generator.py", line 33, in execute
code = pipeline_context.config.llm.generate_code(input, pipeline_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\llm\base.py", line 201, in generate_code
response = self.call(instruction, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\llm\base.py", line 391, in call
self.chat_completion(self.last_prompt, memory)
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\pandasai\llm\base.py", line 365, in chat_completion
response = self.client.create(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\openai\_utils\_utils.py", line 277, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\openai\resources\chat\completions.py", line 606, in create
return self._post(
...
^^^^^^^^^^^^^^
File "c:\Users\kim_h\anaconda3\envs\streamlit\Lib\site-packages\openai\_base_client.py", line 1020, in _request
raise self._make_status_error_from_response(err.response) from None
openai.RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
이런 오류가 발생하면
이는 사용자가 설정된 사용 한도를 초과했다는 의미입니다. 즉, 현재 구독한 요금제에서 사용할 수 있는 API 호출 수를 초과했거나, 잔여 할당량이 없는 상태입니다.
요금제를 확인하거나 할당량을 증가하거나 해야합니다.
요금제 확인: 사용 중인 요금제를 확인하고, 할당량이 충분한지 점검하세요.
할당량 증가: 필요하다면 요금제를 업그레이드하거나 할당량을 늘리는 방법을 고려할 수 있습니다.