mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Litellm dev 12 30 2024 p2 (#7495)
* test(azure_openai_o1.py): initial commit with testing for azure openai o1 preview model * fix(base_llm_unit_tests.py): handle azure o1 preview response format tests skip as o1 on azure doesn't support tool calling yet * fix: initial commit of azure o1 handler using openai caller simplifies calling + allows fake streaming logic alr. implemented for openai to just work * feat(azure/o1_handler.py): fake o1 streaming for azure o1 models azure does not currently support streaming for o1 * feat(o1_transformation.py): support overriding 'should_fake_stream' on azure/o1 via 'supports_native_streaming' param on model info enables user to toggle on when azure allows o1 streaming without needing to bump versions * style(router.py): remove 'give feedback/get help' messaging when router is used Prevents noisy messaging Closes https://github.com/BerriAI/litellm/issues/5942 * fix(types/utils.py): handle none logprobs Fixes https://github.com/BerriAI/litellm/issues/328 * fix(exception_mapping_utils.py): fix error str unbound error * refactor(azure_ai/): move to openai_like chat completion handler allows for easy swapping of api base url's (e.g. ai.services.com) Fixes https://github.com/BerriAI/litellm/issues/7275 * refactor(azure_ai/): move to base llm http handler * fix(azure_ai/): handle differing api endpoints * fix(azure_ai/): make sure all unit tests are passing * fix: fix linting errors * fix: fix linting errors * fix: fix linting error * fix: fix linting errors * fix(azure_ai/transformation.py): handle extra body param * fix(azure_ai/transformation.py): fix max retries param handling * fix: fix test * test(test_azure_o1.py): fix test * fix(llm_http_handler.py): support handling azure ai unprocessable entity error * fix(llm_http_handler.py): handle sync invalid param error for azure ai * fix(azure_ai/): streaming support with base_llm_http_handler * fix(llm_http_handler.py): working sync stream calls with unprocessable entity handling for azure ai * fix: fix linting errors * fix(llm_http_handler.py): fix linting error * fix(azure_ai/): handle cohere tool call invalid index param error
This commit is contained in:
parent
0f1b298fe0
commit
0120176541
42 changed files with 638 additions and 192 deletions
|
@ -2002,6 +2002,7 @@ def get_litellm_params(
|
|||
custom_prompt_dict: Optional[dict] = None,
|
||||
litellm_metadata: Optional[dict] = None,
|
||||
disable_add_transform_inline_image_block: Optional[bool] = None,
|
||||
drop_params: Optional[bool] = None,
|
||||
):
|
||||
litellm_params = {
|
||||
"acompletion": acompletion,
|
||||
|
@ -2035,6 +2036,7 @@ def get_litellm_params(
|
|||
"custom_prompt_dict": custom_prompt_dict,
|
||||
"litellm_metadata": litellm_metadata,
|
||||
"disable_add_transform_inline_image_block": disable_add_transform_inline_image_block,
|
||||
"drop_params": drop_params,
|
||||
}
|
||||
return litellm_params
|
||||
|
||||
|
@ -6345,3 +6347,44 @@ def extract_duration_from_srt_or_vtt(srt_or_vtt_content: str) -> Optional[float]
|
|||
durations.append(total_seconds)
|
||||
|
||||
return max(durations) if durations else None
|
||||
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
def _add_path_to_api_base(api_base: str, ending_path: str) -> str:
|
||||
"""
|
||||
Adds an ending path to an API base URL while preventing duplicate path segments.
|
||||
|
||||
Args:
|
||||
api_base: Base URL string
|
||||
ending_path: Path to append to the base URL
|
||||
|
||||
Returns:
|
||||
Modified URL string with proper path handling
|
||||
"""
|
||||
original_url = httpx.URL(api_base)
|
||||
base_url = original_url.copy_with(params={}) # Removes query params
|
||||
base_path = original_url.path.rstrip("/")
|
||||
end_path = ending_path.lstrip("/")
|
||||
|
||||
# Split paths into segments
|
||||
base_segments = [s for s in base_path.split("/") if s]
|
||||
end_segments = [s for s in end_path.split("/") if s]
|
||||
|
||||
# Find overlapping segments from the end of base_path and start of ending_path
|
||||
final_segments = []
|
||||
for i in range(len(base_segments)):
|
||||
if base_segments[i:] == end_segments[: len(base_segments) - i]:
|
||||
final_segments = base_segments[:i] + end_segments
|
||||
break
|
||||
else:
|
||||
# No overlap found, just combine all segments
|
||||
final_segments = base_segments + end_segments
|
||||
|
||||
# Construct the new path
|
||||
modified_path = "/" + "/".join(final_segments)
|
||||
modified_url = base_url.copy_with(path=modified_path)
|
||||
|
||||
# Re-add the original query parameters
|
||||
return str(modified_url.copy_with(params=original_url.params))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue