mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
feat: add support for copilot provider (#8577)
* feat: add support for copilot provider * test: add tests for github copilot * chore: clean up github copilot authenticator * test: add test for github copilot authenticator * test: add test for github copilot for sonnet 3.7 thought model --------- Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
This commit is contained in:
parent
312286c588
commit
7ccccff39a
11 changed files with 801 additions and 4 deletions
37
litellm/llms/github_copilot/chat/transformation.py
Normal file
37
litellm/llms/github_copilot/chat/transformation.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from typing import Optional, Tuple
|
||||
|
||||
|
||||
from litellm.llms.openai.openai import OpenAIConfig
|
||||
|
||||
from ..authenticator import Authenticator
|
||||
from ..constants import GetAPIKeyError
|
||||
from litellm.exceptions import AuthenticationError
|
||||
|
||||
|
||||
class GithubCopilotConfig(OpenAIConfig):
|
||||
def __init__(
|
||||
self,
|
||||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
custom_llm_provider: str = "openai",
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.authenticator = Authenticator()
|
||||
|
||||
def _get_openai_compatible_provider_info(
|
||||
self,
|
||||
model: str,
|
||||
api_base: Optional[str],
|
||||
api_key: Optional[str],
|
||||
custom_llm_provider: str,
|
||||
) -> Tuple[Optional[str], Optional[str], str]:
|
||||
api_base = "https://api.githubcopilot.com"
|
||||
try:
|
||||
dynamic_api_key = self.authenticator.get_api_key()
|
||||
except GetAPIKeyError as e:
|
||||
raise AuthenticationError(
|
||||
model=model,
|
||||
llm_provider=custom_llm_provider,
|
||||
message=str(e),
|
||||
)
|
||||
return api_base, dynamic_api_key, custom_llm_provider
|
Loading…
Add table
Add a link
Reference in a new issue