dborodin836 / TF2-GPTChatBot

An AI-powered chatbot for Team Fortress 2 fans and players.
GNU General Public License v3.0
13 stars 1 forks source link

The chatbot stops working after attempting to chat with GPT using an incorrect API key. #97

Closed teufortressIndustries closed 8 months ago

teufortressIndustries commented 8 months ago

Users can intentionally type !pc or other !gpt commands, which causes a fatal error. The software should ignore the error to prevent the chatbot from malfunctioning. Or make an option to disable GPT commands.

Exception in thread Thread-1 (parse_console_logs_and_build_conversation_history):
Traceback (most recent call last):
  File "C:\AIstuff\TF2-GPTChatBot\modules\api\openai.py", line 127, in get_response
    response = send_gpt_completion_request(conversation_history, username, model=model)
  File "C:\AIstuff\TF2-GPTChatBot\modules\api\openai.py", line 38, in send_gpt_completion_request
    completion = openai.ChatCompletion.create(
  File "C:\AIstuff\TF2-GPTChatBot\venv\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "C:\AIstuff\TF2-GPTChatBot\venv\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "C:\AIstuff\TF2-GPTChatBot\venv\lib\site-packages\openai\api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "C:\AIstuff\TF2-GPTChatBot\venv\lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(
  File "C:\AIstuff\TF2-GPTChatBot\venv\lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
    raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: sk-11111***************************************1111. You can find your API key at https://platform.openai.com/account/api-keys.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\M8705\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Users\M8705\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\AIstuff\TF2-GPTChatBot\modules\chat.py", line 74, in parse_console_logs_and_build_conversation_history
    controller.process_line(logline)
  File "C:\AIstuff\TF2-GPTChatBot\modules\command_controllers.py", line 108, in process_line
    handler(logline, self.__shared)
  File "C:\AIstuff\TF2-GPTChatBot\modules\commands\openai.py", line 41, in handle_user_chat
    conv_his = handle_cgpt_request(
  File "C:\AIstuff\TF2-GPTChatBot\modules\api\openai.py", line 72, in handle_cgpt_request
    response = get_response(conversation_history.get_messages_array(), username, model)
  File "C:\AIstuff\TF2-GPTChatBot\modules\api\openai.py", line 141, in get_response
    main_logger(f"Unhandled error happened! Cancelling ({e})")
TypeError: 'Logger' object is not callable

image