mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
distil
This commit is contained in:
@@ -92,9 +92,6 @@ class Instructions:
|
||||
log_handlers: List[logging.Handler] = None,
|
||||
finetune_format: FinetuneFormat = FinetuneFormat.MESSAGES,
|
||||
indent: int = 2,
|
||||
<<<<<<< HEAD
|
||||
):
|
||||
=======
|
||||
include_code_body: bool = False,
|
||||
):
|
||||
"""
|
||||
@@ -107,16 +104,12 @@ class Instructions:
|
||||
:param indent: Indentation to use for finetuning.
|
||||
:param include_code_body: Whether to include the code body in the finetuning.
|
||||
"""
|
||||
>>>>>>> distil
|
||||
self.name = name
|
||||
self.id = id or str(uuid.uuid4())
|
||||
self.unique_id = str(uuid.uuid4())
|
||||
self.finetune_format = finetune_format
|
||||
self.indent = indent
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
self.include_code_body = include_code_body
|
||||
>>>>>>> distil
|
||||
|
||||
self.logger = logging.getLogger(self.name)
|
||||
for handler in log_handlers or []:
|
||||
@@ -127,10 +120,7 @@ class Instructions:
|
||||
*args,
|
||||
name: str = None,
|
||||
mode: str = "distil",
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
model: str = "gpt-3.5-turbo",
|
||||
>>>>>>> distil
|
||||
fine_tune_format: FinetuneFormat = None,
|
||||
):
|
||||
"""
|
||||
@@ -154,10 +144,6 @@ class Instructions:
|
||||
"""
|
||||
allowed_modes = {"distil", "dispatch"}
|
||||
assert mode in allowed_modes, f"Must be in {allowed_modes}"
|
||||
<<<<<<< HEAD
|
||||
assert mode == "distil", "Only distil mode is supported at the moment."
|
||||
=======
|
||||
>>>>>>> distil
|
||||
|
||||
if fine_tune_format is None:
|
||||
fine_tune_format = self.finetune_format
|
||||
@@ -165,8 +151,6 @@ class Instructions:
|
||||
def _wrap_distil(fn):
|
||||
msg = f"Return type hint for {fn} must subclass `pydantic.BaseModel'"
|
||||
assert is_return_type_base_model_or_instance(fn), msg
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
return_base_model = inspect.signature(fn).return_annotation
|
||||
|
||||
@functools.wraps(fn)
|
||||
@@ -181,7 +165,6 @@ class Instructions:
|
||||
return openai.ChatCompletion.create(
|
||||
**openai_kwargs, model=model, response_model=return_base_model
|
||||
)
|
||||
>>>>>>> distil
|
||||
|
||||
@functools.wraps(fn)
|
||||
def _distil(*args, **kwargs):
|
||||
@@ -192,15 +175,11 @@ class Instructions:
|
||||
|
||||
return resp
|
||||
|
||||
<<<<<<< HEAD
|
||||
return _distil
|
||||
=======
|
||||
if mode == "dispatch":
|
||||
return _dispatch
|
||||
|
||||
if mode == "distil":
|
||||
return _distil
|
||||
>>>>>>> distil
|
||||
|
||||
if len(args) == 1 and callable(args[0]):
|
||||
return _wrap_distil(args[0])
|
||||
|
||||
Reference in New Issue
Block a user