(Refactor) Code Quality improvement - use Common base handler for Cohere (#7117)

* fix use new format for Cohere config

* fix base llm http handler

* Litellm code qa common config (#7116)

* feat(base_llm): initial commit for common base config class

Addresses code qa critique https://github.com/andrewyng/aisuite/issues/113#issuecomment-2512369132

* feat(base_llm/): add transform request/response abstract methods to base config class

---------

Co-authored-by: Krrish Dholakia <krrishdholakia@gmail.com>

* use base transform helpers

* use base_llm_http_handler for cohere

* working cohere using base llm handler

* add async cohere chat completion support on base handler

* fix completion code

* working sync cohere stream

* add async support cohere_chat

* fix types get_model_response_iterator

* async / sync tests cohere

* feat  cohere using base llm class

* fix linting errors

* fix _abc error

* add cohere params to transformation

* remove old cohere file

* fix type error

* fix merge conflicts

* fix cohere merge conflicts

* fix linting error

* fix litellm.llms.custom_httpx.http_handler.HTTPHandler.post

* fix passing cohere specific params

---------

Co-authored-by: Krrish Dholakia <krrishdholakia@gmail.com>
This commit is contained in:
Ishaan Jaff 2024-12-09 17:45:29 -08:00 committed by GitHub
parent 5bbf906c83
commit ff7c95694d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 933 additions and 720 deletions

View file

@ -1,3 +1,5 @@
from typing import Optional
from litellm.llms.base_llm.transformation import BaseLLMException
@ -6,7 +8,7 @@ class CohereError(BaseLLMException):
super().__init__(status_code=status_code, message=message)
def validate_environment(*, api_key: str, headers: dict) -> dict:
def validate_environment(*, api_key: Optional[str], headers: dict) -> dict:
headers.update(
{
"Request-Source": "unspecified:litellm",