Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
albeorla opened this issue Jan 22, 2024 · 2 comments

Comments

@albeorla
Copy link

albeorla commented Jan 22, 2024

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 in ."
  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 albeorla changed the title BadRequestError on Chat Completion Request: Invalid Request Format with Extra Fields BadRequest Error on OpenAI Completion Request: "extra fields not permitted (type=value_error.extra)" in taskweaver/llm/openai.py:163 Jan 22, 2024
@albeorla albeorla changed the title BadRequest Error on OpenAI Completion Request: "extra fields not permitted (type=value_error.extra)" in taskweaver/llm/openai.py:163 OpenAI Completion 400 Error: "extra fields not permitted (type=value_error.extra)" in taskweaver/llm/openai.py:163 Jan 22, 2024
@NikkNoss
Copy link

same problem

@liqul
Copy link
Contributor

liqul commented Apr 9, 2024

close inactive issues

@liqul liqul closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants