Closed theBigTao closed 1 year ago
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
The project description is kind of mis-leading. It does not say anything about setting up api keys and how:
here is the document: https://jupyter-ai.readthedocs.io/en/latest/users/index.html
You can find information about configuring model providers here in the documentation: https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers
The error you're seeing, "RateLimitError: You exceeded your current quota, please check your plan and billing details." suggests a problem with your OpenAI account. In your OpenAI account, you'll need to set up billing and usage limits. You can find more information about rate limits here: https://platform.openai.com/docs/guides/rate-limits/overview
I'm not affiliated with OpenAI, so you will need to contact the company for assistance with your account.
Please update the project description document to explicitly say that API key configuration is a must and how it can be done.
Maybe just moving the section from https://jupyter-ai.readthedocs.io/en/latest/users/index.html#model-providers to https://jupyter-ai.readthedocs.io/en/latest/users/index.html#prerequisites or https://jupyter-ai.readthedocs.io/en/latest/users/index.html#installation should resolve such issues in future? (Or calling it setup/configuration)
@theBigTao I have open https://github.com/jupyterlab/jupyter-ai/pull/330
Fixed via #330, further addressed in #347.
Description
After installation, I typed %load_ext jupyter_ai %%ai chatgpt -f math Generate the 2D heat equation and get errors:
Reproduce
See error below
RateLimitError Traceback (most recent call last) Cell In[8], line 1 ----> 1 get_ipython().run_cell_magic('ai', 'chatgpt -f math', 'Generate the 2D heat equation.\n')
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2430, in InteractiveShell.run_cell_magic(self, magic_name, line, cell) 2428 with self.builtin_trap: 2429 args = (magic_arg_s, cell) -> 2430 result = fn(*args, **kwargs) 2432 # The code below prevents the output from being displayed 2433 # when using magics with decodator @output_can_be_silenced 2434 # when the last Python token in the expression is a ';'. 2435 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/jupyter_ai_magics/magics.py:603, in AiMagics.ai(self, line, cell) 600 ip = get_ipython() 601 prompt = prompt.format_map(FormatDict(ip.user_ns)) --> 603 return self.run_ai_cell(args, prompt)
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/jupyter_ai_magics/magics.py:545, in AiMagics.run_ai_cell(self, args, prompt) 542 provider = Provider(**provider_params) 544 # generate output from model via provider --> 545 result = provider.generate([prompt]) 546 output = result.generations[0][0].text 548 # if openai-chat, append exchange to transcript
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/base.py:227, in BaseLLM.generate(self, prompts, stop, callbacks, tags, kwargs) 221 raise ValueError( 222 "Asked to cache, but no cache found at
langchain.cache
." 223 ) 224 run_managers = callback_manager.on_llm_start( 225 dumpd(self), prompts, invocation_params=params, options=options 226 ) --> 227 output = self._generate_helper( 228 prompts, stop, run_managers, bool(new_arg_supported), kwargs 229 ) 230 return output 231 if len(missing_prompts) > 0:File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/base.py:178, in BaseLLM._generate_helper(self, prompts, stop, run_managers, new_arg_supported, **kwargs) 176 for run_manager in run_managers: 177 run_manager.on_llm_error(e) --> 178 raise e 179 flattened_outputs = output.flatten() 180 for manager, flattened_output in zip(run_managers, flattened_outputs):
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/base.py:165, in BaseLLM._generate_helper(self, prompts, stop, run_managers, new_arg_supported, kwargs) 155 def _generate_helper( 156 self, 157 prompts: List[str], (...) 161 kwargs: Any, 162 ) -> LLMResult: 163 try: 164 output = ( --> 165 self._generate( 166 prompts, 167 stop=stop, 168 # TODO: support multiple run managers 169 run_manager=run_managers[0] if run_managers else None, 170 **kwargs, 171 ) 172 if new_arg_supported 173 else self._generate(prompts, stop=stop) 174 ) 175 except (KeyboardInterrupt, Exception) as e: 176 for run_manager in run_managers:
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/openai.py:822, in OpenAIChat._generate(self, prompts, stop, run_manager, kwargs) 818 return LLMResult( 819 generations=[[Generation(text=response)]], 820 ) 821 else: --> 822 full_response = completion_with_retry(self, messages=messages, params) 823 llm_output = { 824 "token_usage": full_response["usage"], 825 "model_name": self.model_name, 826 } 827 return LLMResult( 828 generations=[ 829 [Generation(text=full_response["choices"][0]["message"]["content"])] 830 ], 831 llm_output=llm_output, 832 )
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/openai.py:106, in completion_with_retry(llm, kwargs) 102 @retry_decorator 103 def _completion_with_retry(kwargs: Any) -> Any: 104 return llm.client.create(kwargs) --> 106 return _completion_with_retry(kwargs)
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/tenacity/init.py:289, in BaseRetrying.wraps..wrapped_f(*args, kw)
287 @functools.wraps(f)
288 def wrapped_f(*args: t.Any, *kw: t.Any) -> t.Any:
--> 289 return self(f, args, kw)
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/tenacity/init.py:379, in Retrying.call(self, fn, *args, **kwargs) 377 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs) 378 while True: --> 379 do = self.iter(retry_state=retry_state) 380 if isinstance(do, DoAttempt): 381 try:
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/tenacity/init.py:325, in BaseRetrying.iter(self, retry_state) 323 retry_exc = self.retry_error_cls(fut) 324 if self.reraise: --> 325 raise retry_exc.reraise() 326 raise retry_exc from fut.exception() 328 if self.wait:
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/tenacity/init.py:158, in RetryError.reraise(self) 156 def reraise(self) -> t.NoReturn: 157 if self.last_attempt.failed: --> 158 raise self.last_attempt.result() 159 raise self
File ~/.pyenv/versions/3.9.11/lib/python3.9/concurrent/futures/_base.py:439, in Future.result(self, timeout) 437 raise CancelledError() 438 elif self._state == FINISHED: --> 439 return self.__get_result() 441 self._condition.wait(timeout) 443 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
File ~/.pyenv/versions/3.9.11/lib/python3.9/concurrent/futures/_base.py:391, in Future.__get_result(self) 389 if self._exception: 390 try: --> 391 raise self._exception 392 finally: 393 # Break a reference cycle with the exception in self._exception 394 self = None
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/tenacity/init.py:382, in Retrying.call(self, fn, *args, *kwargs) 380 if isinstance(do, DoAttempt): 381 try: --> 382 result = fn(args, **kwargs) 383 except BaseException: # noqa: B902 384 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/langchain/llms/openai.py:104, in completion_with_retry.._completion_with_retry(kwargs)
102 @retry_decorator
103 def _completion_with_retry(kwargs: Any) -> Any:
--> 104 return llm.client.create(**kwargs)
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/openai/api_resources/chat_completion.py:25, in ChatCompletion.create(cls, *args, *kwargs) 23 while True: 24 try: ---> 25 return super().create(args, **kwargs) 26 except TryAgain as e: 27 if timeout is not None and time.time() > start + timeout:
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, params) 127 @classmethod 128 def create( 129 cls, (...) 136 params, 137 ): 138 ( 139 deployment_id, 140 engine, (...) 150 api_key, api_base, api_type, apiversion, organization, **params 151 ) --> 153 response, , api_key = requestor.request( 154 "post", 155 url, 156 params=params, 157 headers=headers, 158 stream=stream, 159 request_id=request_id, 160 request_timeout=request_timeout, 161 ) 163 if stream: 164 # must be an iterator 165 assert not isinstance(response, OpenAIResponse)
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/openai/api_requestor.py:230, in APIRequestor.request(self, method, url, params, headers, files, stream, request_id, request_timeout) 209 def request( 210 self, 211 method, (...) 218 request_timeout: Optional[Union[float, Tuple[float, float]]] = None, 219 ) -> Tuple[Union[OpenAIResponse, Iterator[OpenAIResponse]], bool, str]: 220 result = self.request_raw( 221 method.lower(), 222 url, (...) 228 request_timeout=request_timeout, 229 ) --> 230 resp, got_stream = self._interpret_response(result, stream) 231 return resp, got_stream, self.api_key
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/openai/api_requestor.py:624, in APIRequestor._interpret_response(self, result, stream) 616 return ( 617 self._interpret_response_line( 618 line, result.status_code, result.headers, stream=True 619 ) 620 for line in parse_stream(result.iter_lines()) 621 ), True 622 else: 623 return ( --> 624 self._interpret_response_line( 625 result.content.decode("utf-8"), 626 result.status_code, 627 result.headers, 628 stream=False, 629 ), 630 False, 631 )
File ~/.pyenv/versions/3.9.11/lib/python3.9/site-packages/openai/api_requestor.py:687, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream) 685 stream_error = stream and "error" in resp.data 686 if stream_error or not 200 <= rcode < 300: --> 687 raise self.handle_error_response( 688 rbody, rcode, resp.data, rheaders, stream_error=stream_error 689 ) 690 return resp
RateLimitError: You exceeded your current quota, please check your plan and billing details.
Expected behavior
Succeeds in generating 2D heat equation.
Context
Troubleshoot Output
Command Line Output
Browser Output