TaskWeaver icon indicating copy to clipboard operation
TaskWeaver copied to clipboard

OpenAI Completion 400 Error: "extra fields not permitted (type=value_error.extra)" in `taskweaver/llm/openai.py:163`

Open albeorla opened this issue 1 year ago • 1 comments
trafficstars

Describe the bug The system encountered a 400 error (BadRequestError) when processing a chat completion request. This error appears to be linked to an issue with the request format.

To Reproduce Steps to reproduce the behavior:

  1. Start the TaskWeaver service.
  2. Input the user query: "I need to bring my plant in to a local nursery called <SomeStore> in <SomeTown>."
  3. The system attempts to process this request.
  4. The system encounters a BadRequestError with a message indicating a validation error for the request body, specifically mentioning "extra fields not permitted."

Expected behavior The expected behavior was for the system to process the query successfully and provide an appropriate response or action plan.

Screenshots Not applicable.

Environment Information

  • OS: macos 14.2.1 (23C71)
  • Python Version: 3.10
  • LLM used: GPT-4 Vision Preview

Additional context The error suggests there may be an issue with the format or parameters of the request being sent to the OpenAI API. It may involve unexpected or extra fields in the request body that are not permitted. This could be due to changes in API specifications or incorrect request structuring.

** Terminal Dump

|_   _|_ _ ___| | _ | |     / /__  ____ __   _____  _____
  | |/ _` / __| |/ /| | /| / / _ \/ __ `/ | / / _ \/ ___/
  | | (_| \__ \   < | |/ |/ /  __/ /_/ /| |/ /  __/ /
  |_|\__,_|___/_|\_\|__/|__/\___/\__,_/ |___/\___/_/
=========================================================
 TaskWeaver ▶  I am TaskWeaver, an AI assistant. To get started, could you please enter your request?
    Human   ▶  I need to bring my plant in to a local nursery called <redacted> in <redacted>
 ╭───< Planner >
Exception in thread Thread-3 (base_stream_puller):   <=💡=>
Traceback (most recent call last):
  File "/Users/aorlando/Development/TaskWeaver/taskweaver/llm/openai.py", line 163, in chat_completion
    res: Any = self.client.chat.completions.create(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/site-packages/openai/_utils/_utils.py", line 271, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/site-packages/openai/resources/chat/completions.py", line 648, in create
    return self._post(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/site-packages/openai/_base_client.py", line 1179, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/site-packages/openai/_base_client.py", line 868, in request
    return self._request(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/site-packages/openai/_base_client.py", line 959, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': '1 validation error for Request\nbody -> response_format\n  extra fields not permitted (type=value_error.extra)', 'type': 'invalid_request_error', 'param': None, 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/taskweaver/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/aorlando/Development/TaskWeaver/taskweaver/llm/__init__.py", line 162, in base_stream_puller
    for msg in stream:
  File "/Users/aorlando/Development/TaskWeaver/taskweaver/llm/openai.py", line 218, in chat_completion
    raise Exception(f"OpenAI API request was invalid: {e}")
Exception: OpenAI API request was invalid: Error code: 400 - {'error': {'message': '1 validation error for Request\nbody -> response_format\n  extra fields not permitted (type=value_error.extra)', 'type': 'invalid_request_error', 'param': None, 'code': None}}

albeorla avatar Jan 22 '24 05:01 albeorla

same problem

NikkNoss avatar Jan 24 '24 05:01 NikkNoss

close inactive issues

liqul avatar Apr 09 '24 02:04 liqul

same problem

sir3mat avatar Jul 18 '24 15:07 sir3mat

same problem

So, the problem should be caused by request format issue as we have not support for vision models. We are planning for it right now.

liqul avatar Jul 19 '24 02:07 liqul