(feat) set organization on litellm.completion

This commit is contained in:
ishaan-jaff 2024-01-30 10:56:36 -08:00
parent ae4e273db7
commit cf4b1afa52

View file

@ -450,6 +450,7 @@ def completion(
num_retries = kwargs.get("num_retries", None) ## deprecated num_retries = kwargs.get("num_retries", None) ## deprecated
max_retries = kwargs.get("max_retries", None) max_retries = kwargs.get("max_retries", None)
context_window_fallback_dict = kwargs.get("context_window_fallback_dict", None) context_window_fallback_dict = kwargs.get("context_window_fallback_dict", None)
organization = kwargs.get("organization", None)
### CUSTOM MODEL COST ### ### CUSTOM MODEL COST ###
input_cost_per_token = kwargs.get("input_cost_per_token", None) input_cost_per_token = kwargs.get("input_cost_per_token", None)
output_cost_per_token = kwargs.get("output_cost_per_token", None) output_cost_per_token = kwargs.get("output_cost_per_token", None)
@ -787,7 +788,8 @@ def completion(
or "https://api.openai.com/v1" or "https://api.openai.com/v1"
) )
openai.organization = ( openai.organization = (
litellm.organization organization
or litellm.organization
or get_secret("OPENAI_ORGANIZATION") or get_secret("OPENAI_ORGANIZATION")
or None # default - https://github.com/openai/openai-python/blob/284c1799070c723c6a553337134148a7ab088dd8/openai/util.py#L105 or None # default - https://github.com/openai/openai-python/blob/284c1799070c723c6a553337134148a7ab088dd8/openai/util.py#L105
) )
@ -827,6 +829,7 @@ def completion(
timeout=timeout, timeout=timeout,
custom_prompt_dict=custom_prompt_dict, custom_prompt_dict=custom_prompt_dict,
client=client, # pass AsyncOpenAI, OpenAI client client=client, # pass AsyncOpenAI, OpenAI client
organization=organization,
) )
except Exception as e: except Exception as e:
## LOGGING - log the original exception returned ## LOGGING - log the original exception returned