text-generation-webui icon indicating copy to clipboard operation
text-generation-webui copied to clipboard

405 Method Not Allowed

Open adaaaaaa opened this issue 5 months ago • 8 comments

Describe the bug

curl -v http://127.0.0.1:8000/v1/chat/completions

  • Trying 127.0.0.1:8000...
  • Connected to 127.0.0.1 (127.0.0.1) port 8000

GET /v1/chat/completions HTTP/1.1 Host: 127.0.0.1:8000 User-Agent: curl/8.6.0 Accept: /

< HTTP/1.1 405 Method Not Allowed < date: Fri, 22 Mar 2024 23:05:10 GMT < server: uvicorn < allow: POST < content-length: 31 < content-type: application/json <

  • Connection #0 to host 127.0.0.1 left intact {"detail":"Method Not Allowed"}%

Is there an existing issue for this?

  • [X] I have searched the existing issues

Reproduction

python server.py --trust-remote-code --extension openai --listen --api --api-port 8000

Screenshot

No response

Logs

Exception in ASGI application
Traceback (most recent call last):
  File "/home/nano/.local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/applications.py", line 116, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    await app(scope, receive, sender)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 746, in __call__
    await route.handle(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    await app(scope, receive, sender)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 70, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app
    raise e
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/script.py", line 137, in openai_chat_completions
    response = OAIcompletions.chat_completions(to_dict(request_data), is_legacy=is_legacy)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/completions.py", line 536, in chat_completions
    return deque(generator, maxlen=1).pop()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/completions.py", line 315, in chat_completions_common
    prompt = generate_chat_prompt(user_input, generate_params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/modules/chat.py", line 97, in generate_chat_prompt
    user_bio=replace_character_names(state['user_bio'], state['name1'], state['name2']),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/modules/chat.py", line 636, in replace_character_names
    text = text.replace('{{user}}', name1).replace('{{char}}', name2)
           ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
Exception in ASGI application
Traceback (most recent call last):
  File "/home/nano/.local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/applications.py", line 116, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    await app(scope, receive, sender)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 746, in __call__
    await route.handle(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
    raise exc
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
    await app(scope, receive, sender)
  File "/home/nano/.local/lib/python3.11/site-packages/starlette/routing.py", line 70, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app
    raise e
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nano/.local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/script.py", line 137, in openai_chat_completions
    response = OAIcompletions.chat_completions(to_dict(request_data), is_legacy=is_legacy)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/completions.py", line 536, in chat_completions
    return deque(generator, maxlen=1).pop()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/extensions/openai/completions.py", line 315, in chat_completions_common
    prompt = generate_chat_prompt(user_input, generate_params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/modules/chat.py", line 97, in generate_chat_prompt
    user_bio=replace_character_names(state['user_bio'], state['name1'], state['name2']),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/text-generation-webui/modules/chat.py", line 636, in replace_character_names
    text = text.replace('{{user}}', name1).replace('{{char}}', name2)
           ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

System Info

archlinux
Kernel: 6.6.22-1-lts

curl -v http://127.0.0.1:8000/v1/chat/completions \ -H "Content-Type: application/json"
-d '{ "messages": [ { "role": "user", "content": "Hello! Who are you?" } ], "mode": "chat", "character": "Example" }'

  • Trying 127.0.0.1:8000...
  • Connected to 127.0.0.1 (127.0.0.1) port 8000

POST /v1/chat/completions HTTP/1.1 Host: 127.0.0.1:8000 User-Agent: curl/8.6.0 Accept: / Content-Type: application/json Content-Length: 158

< HTTP/1.1 500 Internal Server Error < date: Fri, 22 Mar 2024 22:59:50 GMT < server: uvicorn < content-length: 21 < content-type: text/plain; charset=utf-8 <

  • Connection #0 to host 127.0.0.1 left intact Internal Server Error%

adaaaaaa avatar Mar 22 '24 23:03 adaaaaaa

I'm having the same issue here as well

MatheusDaros avatar Mar 24 '24 04:03 MatheusDaros

I also got this error it seems to be in the chat endpoint.

zimNMM avatar Mar 25 '24 18:03 zimNMM

I'm having this error as well

EduardoABG avatar Mar 25 '24 18:03 EduardoABG

Having the same error with the exact same message

CRPrinzler avatar Mar 27 '24 08:03 CRPrinzler

I'm having the same issue here as well

shiniu0606 avatar Mar 27 '24 10:03 shiniu0606

https://github.com/oobabooga/text-generation-webui/pull/5716/files

the error is in chatcompletions and there were changes

thistleknot avatar Mar 28 '24 00:03 thistleknot

solution, add a user_bio key value https://github.com/oobabooga/text-generation-webui/issues/5761

thistleknot avatar Mar 28 '24 02:03 thistleknot

I tried to go back to snapshot 2024-03-10 without success.

ruizcrp avatar Apr 09 '24 10:04 ruizcrp