mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
(feat) openrouter set transforms=[] default
This commit is contained in:
parent
b15682bc1f
commit
6b272076d7
2 changed files with 30 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from typing import List
|
||||
from typing import List, Dict
|
||||
import types
|
||||
|
||||
class OpenrouterConfig():
|
||||
"""
|
||||
|
|
@ -6,6 +7,24 @@ class OpenrouterConfig():
|
|||
|
||||
"""
|
||||
# OpenRouter-only parameters
|
||||
transforms: List[str] = []
|
||||
models: List[str] = []
|
||||
route: str = ''
|
||||
extra_body: Dict[str, List[str]] = {
|
||||
'transforms': [] # default transforms to []
|
||||
}
|
||||
|
||||
|
||||
def __init__(self,
|
||||
transforms: List[str] = [],
|
||||
models: List[str] = [],
|
||||
route: str = '',
|
||||
) -> None:
|
||||
locals_ = locals()
|
||||
for key, value in locals_.items():
|
||||
if key != 'self' and value is not None:
|
||||
setattr(self.__class__, key, value)
|
||||
|
||||
@classmethod
|
||||
def get_config(cls):
|
||||
return {k: v for k, v in cls.__dict__.items()
|
||||
if not k.startswith('__')
|
||||
and not isinstance(v, (types.FunctionType, types.BuiltinFunctionType, classmethod, staticmethod))
|
||||
and v is not None}
|
||||
|
|
@ -52,6 +52,7 @@ from .llms import (
|
|||
cohere,
|
||||
petals,
|
||||
oobabooga,
|
||||
openrouter,
|
||||
palm,
|
||||
vertex_ai,
|
||||
maritalk)
|
||||
|
|
@ -1026,14 +1027,17 @@ def completion(
|
|||
}
|
||||
)
|
||||
|
||||
## Load Config
|
||||
config = openrouter.OpenrouterConfig.get_config()
|
||||
for k, v in config.items():
|
||||
if k not in optional_params: # completion(top_k=3) > anthropic_config(top_k=3) <- allows for dynamic variables to be passed in
|
||||
optional_params[k] = v
|
||||
|
||||
data = {
|
||||
"model": model,
|
||||
"messages": messages,
|
||||
**optional_params
|
||||
}
|
||||
## LOGGING
|
||||
logging.pre_call(input=messages, api_key=openai.api_key, additional_args={"complete_input_dict": data, "headers": headers})
|
||||
## COMPLETION CALL
|
||||
|
||||
## COMPLETION CALL
|
||||
response = openai_chat_completions.completion(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue