O Código final que é disponibilizado não funciona, desde a Quarta Parte do Curso, toda a minha implementação retorna com erro, decidi copiar o projeto final disponibilizado pela própria plataforma para verificar qual o problema e ainda assim, retorna erro. Quando faço uma pergunta ao Bot, ele retorna um erro de api, a resposta do bot é a seguinte: Erro no GPT: Messages.create() got an unexpected keyword argument 'file_ids'
Esse file_ids é usado pelo próprio instrutor, e como eu disse para verificar se não era um erro meu de codificação, estou rodando o código final disponibilizado pela Alura. Isso porque tive que acrescentar na mão uma condição abaixo porque o código original retorna na verdade outr erro:
def chat():
prompt = request.json["msg"]
resposta = bot(prompt)
if isinstance(resposta,str):
return resposta
else:
texto_resposta = resposta.content[0].text.value
return texto_resposta
Da forma original disponibilizada:
def chat():
prompt = request.json["msg"]
resposta = bot(prompt)
texto_resposta = resposta.content[0].text.value
return texto_resposta
Retorna o erro:
AttributeError
AttributeError: 'str' object has no attribute 'content'
Traceback (most recent call last)
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1498, in call
return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1476, in wsgi_app
response = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request
rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\dtiDigital\Documents\app.py", line 131, in chat
texto_resposta = resposta.content[0].text.value ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'content'
This is the Copy/Paste friendly version of the traceback.
Traceback (most recent call last): File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1498, in call return self.wsgi_app(environ, start_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1476, in wsgi_app response = self.handle_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 1473, in wsgi_app response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dtiDigital\Documents\chatbot\Lib\site-packages\flask\app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\dtiDigital\Documents\app.py", line 131, in chat texto_resposta = resposta.content[0].text.value ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: 'str' object has no attribute 'content'
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.