oci: drop params automatically and add DEDICATED Support
This commit is contained in:
parent
d4830e34e5
commit
aeae6cffe4
@ -207,9 +207,9 @@ class OCIChatConfig(BaseConfig):
|
||||
alias = open_ai_to_oci_param_map.get(key)
|
||||
|
||||
if alias is False:
|
||||
if drop_params:
|
||||
continue
|
||||
|
||||
# Workaround for mypy issue
|
||||
#if drop_params:
|
||||
continue
|
||||
raise Exception(f"param `{key}` is not supported on OCI")
|
||||
|
||||
if alias is None:
|
||||
@ -450,12 +450,26 @@ class OCIChatConfig(BaseConfig):
|
||||
"Cohere models are not yet supported in the litellm OCI chat completion endpoint. Use the Cohere API directly."
|
||||
)
|
||||
else:
|
||||
data = OCICompletionPayload(
|
||||
compartmentId=oci_compartment_id,
|
||||
servingMode=OCIServingMode(
|
||||
oci_serving_mode = optional_params.get("oci_serving_mode", "ON_DEMAND")
|
||||
if oci_serving_mode not in ["ON_DEMAND", "DEDICATED"]:
|
||||
raise Exception(
|
||||
"kwarg `oci_serving_mode` must be either 'ON_DEMAND' or 'DEDICATED'"
|
||||
)
|
||||
|
||||
if oci_serving_mode == "DEDICATED":
|
||||
servingMode = OCIServingMode(
|
||||
servingType="DEDICATED",
|
||||
endpointId=model,
|
||||
)
|
||||
else:
|
||||
servingMode = OCIServingMode(
|
||||
servingType="ON_DEMAND",
|
||||
modelId=model,
|
||||
),
|
||||
)
|
||||
|
||||
data = OCICompletionPayload(
|
||||
compartmentId=oci_compartment_id,
|
||||
servingMode=servingMode,
|
||||
chatRequest=OCIChatRequestPayload(
|
||||
apiFormat=vendor.value,
|
||||
messages=adapt_messages_to_generic_oci_standard(messages),
|
||||
@ -601,6 +615,11 @@ class OCIChatConfig(BaseConfig):
|
||||
if "stream" in data:
|
||||
del data["stream"]
|
||||
|
||||
stops = data.get("chatRequest", {}).get("stop")
|
||||
if stops and len(stops) > 8:
|
||||
# mantém apenas os 8 primeiros
|
||||
data["chatRequest"]["stop"] = stops[:8]
|
||||
|
||||
if client is None or isinstance(client, HTTPHandler):
|
||||
client = get_async_httpx_client(llm_provider=LlmProviders.BYTEZ, params={})
|
||||
|
||||
|
||||
@ -100,8 +100,8 @@ class OCIServingMode(BaseModel):
|
||||
"""Defines the serving mode and the model to be used."""
|
||||
|
||||
servingType: str
|
||||
modelId: str
|
||||
|
||||
endpointId: Optional[str] = None
|
||||
modelId: Optional[str] = None
|
||||
|
||||
class OCICompletionPayload(BaseModel):
|
||||
"""Pydantic model for the complete OCI chat request body."""
|
||||
@ -129,7 +129,7 @@ class OCIPromptTokensDetails(BaseModel):
|
||||
|
||||
class OCIResponseUsage(BaseModel):
|
||||
"""Token usage in the OCI response."""
|
||||
|
||||
|
||||
promptTokens: int
|
||||
completionTokens: int
|
||||
totalTokens: int
|
||||
|
||||
Loading…
Reference in New Issue
Block a user