mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
Enable setting default model
value for Completions
add `model` arg to `Completions` class; if you provide a value, it will be used when you create new completions from an instance of the class.
This commit is contained in:
parent
492c9043f6
commit
56e95197c6
1 changed files with 10 additions and 4 deletions
|
@ -98,17 +98,23 @@ class Chat():
|
|||
def __init__(self, params):
|
||||
self.params = params
|
||||
self.completions = Completions(self.params)
|
||||
|
||||
|
||||
class Completions():
|
||||
|
||||
def __init__(self, params):
|
||||
def __init__(self, model, params):
|
||||
self.params = params
|
||||
self.model = model
|
||||
|
||||
def create(self, model, messages, **kwargs):
|
||||
def create(self, messages, model=None, **kwargs):
|
||||
if model is None:
|
||||
if self.model is not None:
|
||||
model = self.model
|
||||
else:
|
||||
raise ValueError("a value for `model` is required)
|
||||
for k, v in kwargs.items():
|
||||
self.params[k] = v
|
||||
response = completion(model=model, messages=messages, **self.params)
|
||||
return response
|
||||
return response
|
||||
|
||||
@client
|
||||
async def acompletion(*args, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue