add text_completion

This commit is contained in:
ishaan-jaff 2023-08-28 08:20:20 -07:00
parent 0dd9231e2c
commit fedd16361f
3 changed files with 13 additions and 8 deletions

View file

@ -91,7 +91,6 @@ def completion(
custom_llm_provider=None,
custom_api_base=None,
litellm_call_id=None,
prompt="", # allow completion to be used as textCompletion or as ChatCompletion
# model specific optional params
# used by text-bison only
top_k=40,
@ -102,8 +101,6 @@ def completion(
try:
if fallbacks != []:
return completion_with_fallbacks(**args)
if messages == [] and prompt!="":
messages = [{"role": "user", "content": prompt}]
if litellm.model_alias_map and model in litellm.model_alias_map:
args["model_alias_map"] = litellm.model_alias_map
model = litellm.model_alias_map[model] # update the model to the actual value if an alias has been passed in
@ -867,6 +864,13 @@ def embedding(
custom_llm_provider="azure" if azure == True else None,
)
###### Text Completion ################
def text_completion(*args, **kwargs):
if 'prompt' in kwargs:
messages = [{'role': 'system', 'content': kwargs['prompt']}]
kwargs['messages'] = messages
kwargs.pop('prompt')
return completion(*args, **kwargs)
####### HELPER FUNCTIONS ################
## Set verbose to true -> ```litellm.set_verbose = True```