mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
adding support for completions endpoint in proxy
This commit is contained in:
parent
b08aea851f
commit
c737462beb
5 changed files with 42 additions and 4 deletions
|
@ -1431,7 +1431,25 @@ def text_completion(*args, **kwargs):
|
|||
messages = [{"role": "system", "content": kwargs["prompt"]}]
|
||||
kwargs["messages"] = messages
|
||||
kwargs.pop("prompt")
|
||||
return completion(*args, **kwargs)
|
||||
response = completion(*args, **kwargs) # assume the response is the openai response object
|
||||
response_2 = {
|
||||
"id": response["id"],
|
||||
"object": "text_completion",
|
||||
"created": response["created"],
|
||||
"model": response["model"],
|
||||
"choices": [
|
||||
{
|
||||
"text": response["choices"][0]["message"]["content"],
|
||||
"index": response["choices"][0]["index"],
|
||||
"logprobs": None,
|
||||
"finish_reason": response["choices"][0]["finish_reason"]
|
||||
}
|
||||
],
|
||||
"usage": response["usage"]
|
||||
}
|
||||
return response_2
|
||||
else:
|
||||
raise ValueError("please pass prompt into the `text_completion` endpoint - `text_completion(model, prompt='hello world')`")
|
||||
|
||||
##### Moderation #######################
|
||||
def moderation(input: str, api_key: Optional[str]=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue