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:
estill01 2023-12-02 19:50:18 -08:00 committed by GitHub
parent 492c9043f6
commit 56e95197c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):