mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(github-copilot): adapt main's new session and router code to the merged branch
This commit is contained in:
parent
cb201da17b
commit
5f9186d1f9
3 changed files with 14 additions and 9 deletions
|
|
@ -4797,11 +4797,11 @@ class Router:
|
|||
- Merges tools from deployment with request (proxy-configured tools + request tools).
|
||||
- On a fallback hop, drops the encrypted reasoning this deployment cannot decrypt, keeping its summary.
|
||||
"""
|
||||
deployment_litellm_params: Final = cast( # cast-ok: a dict or LiteLLM_Params, both answer get
|
||||
deployment_param_lookup: Final = cast( # cast-ok: a dict or LiteLLM_Params, both answer get
|
||||
"DeploymentParamLookup", deployment["litellm_params"]
|
||||
)
|
||||
caller_kwargs: Final = cast("Mapping[str, object]", kwargs) # cast-ok: router call kwargs are a str-keyed dict
|
||||
caller_endpoint_keys: Final = github_copilot_caller_endpoint_keys(deployment_litellm_params, caller_kwargs)
|
||||
caller_endpoint_keys: Final = github_copilot_caller_endpoint_keys(deployment_param_lookup, caller_kwargs)
|
||||
router_defaults: Final = cast( # cast-ok: router default params are a str-keyed dict
|
||||
"Mapping[str, object]", self.default_litellm_params
|
||||
)
|
||||
|
|
@ -4810,7 +4810,7 @@ class Router:
|
|||
value
|
||||
for value in (
|
||||
caller_kwargs.get("drop_params"),
|
||||
deployment_litellm_params.get("drop_params"),
|
||||
deployment_param_lookup.get("drop_params"),
|
||||
router_defaults.get("drop_params"),
|
||||
)
|
||||
if value is not None
|
||||
|
|
|
|||
|
|
@ -7,19 +7,22 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from itertools import chain
|
||||
from dataclasses import dataclass
|
||||
from itertools import chain
|
||||
from typing import Final
|
||||
|
||||
import litellm
|
||||
import openai
|
||||
from litellm.integrations.prometheus import PrometheusLogger
|
||||
from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession
|
||||
from prometheus_client import REGISTRY
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
import litellm
|
||||
from litellm.integrations.prometheus import PrometheusLogger
|
||||
from litellm.llms.github_copilot.github_host import github_host_endpoints
|
||||
from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession
|
||||
|
||||
COPILOT_DEPLOYMENT: Final = "copilot-per-user-deployment"
|
||||
OPERATOR_DEPLOYMENT: Final = "operator-key-deployment"
|
||||
CALLER_SESSION_TOKEN: Final = "caller-copilot-session-token"
|
||||
|
|
@ -77,6 +80,7 @@ _REPORT: Final = TypeAdapter(WorkerReport)
|
|||
def run_copilot_session_worker(api_base: str) -> WorkerReport:
|
||||
completed: Final = subprocess.run(
|
||||
(sys.executable, "-P", __file__, api_base),
|
||||
env={**os.environ, "GITHUB_COPILOT_API_BASE": api_base},
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=WORKER_TIMEOUT_SECONDS,
|
||||
|
|
@ -146,7 +150,7 @@ async def _direct_attempt(api_base: str) -> Outcome:
|
|||
|
||||
async def main(api_base: str) -> None:
|
||||
litellm.callbacks = [PrometheusLogger()] # test-quality-ok: this worker process exits right after the report
|
||||
session: Final = GithubCopilotUserSession(token=CALLER_SESSION_TOKEN, api_base=api_base)
|
||||
session: Final = GithubCopilotUserSession(token=CALLER_SESSION_TOKEN, endpoints=github_host_endpoints("github.com"))
|
||||
router: Final = _router(api_base)
|
||||
outcomes: Final = (
|
||||
await _attempt(router, COPILOT_DEPLOYMENT, github_copilot_user_session=session),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from prometheus_client.samples import Sample
|
|||
import litellm
|
||||
from litellm.constants import LITELLM_LOGGING_NO_UPSTREAM_LLM_CALL
|
||||
from litellm.integrations.prometheus import PrometheusLogger
|
||||
from litellm.llms.github_copilot.github_host import github_host_endpoints
|
||||
from litellm.llms.github_copilot.per_user_auth import GithubCopilotUserSession
|
||||
from litellm.proxy._types import ProxyErrorTypes, ProxyException, UserAPIKeyAuth
|
||||
|
||||
|
|
@ -223,7 +224,7 @@ class TestSkipMetricsValidation:
|
|||
{
|
||||
"litellm_params": {
|
||||
"github_copilot_user_session": GithubCopilotUserSession(
|
||||
token="caller-session-token", api_base="https://api.githubcopilot.com"
|
||||
token="caller-session-token", endpoints=github_host_endpoints("github.com")
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue