From 08b4ca02e1cc3a0848269f54f30a69c02ece7f8e Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Sat, 14 Oct 2023 15:38:57 -0400 Subject: [PATCH] clean up --- examples/distilations/three_digit_mul.py | 2 +- instructor/distil.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/distilations/three_digit_mul.py b/examples/distilations/three_digit_mul.py index 849f3b1..1d3f34c 100644 --- a/examples/distilations/three_digit_mul.py +++ b/examples/distilations/three_digit_mul.py @@ -1,7 +1,7 @@ import logging from pydantic import BaseModel -from instructor.distil import Instructions +from instructor import Instructions logging.basicConfig(level=logging.INFO) diff --git a/instructor/distil.py b/instructor/distil.py index d17f359..c69cdb3 100644 --- a/instructor/distil.py +++ b/instructor/distil.py @@ -79,11 +79,13 @@ class Instructions: id: str = None, log_handlers: List[logging.Handler] = None, finetune_format: FinetuneFormat = FinetuneFormat.MESSAGES, + indent: int = 2, ): self.name = name self.id = id or str(uuid.uuid4()) self.unique_id = str(uuid.uuid4()) self.finetune_format = finetune_format + self.indent = indent self.logger = logging.getLogger(self.name) for handler in log_handlers or []: @@ -167,7 +169,7 @@ class Instructions: if finetune_format == FinetuneFormat.MESSAGES: openai_function_call = openai_schema(base_model).openai_schema - function_definition = get_signature_from_fn(fn).replace(fn.__name__, name) + func_def = get_signature_from_fn(fn).replace(fn.__name__, name) str_args = ", ".join(map(str, args)) str_kwargs = ( @@ -179,17 +181,17 @@ class Instructions: "messages": [ { "role": "system", - "content": f"Predict the results of this function:\n\n{function_definition}", + "content": f"Predict the results of this function:\n\n{func_def}", }, { "role": "user", - "content": f"Return {name}({call_args})", + "content": f"Return `{name}({call_args})`", }, { "role": "assistant", "function_call": { "name": openai_function_call["name"], - "arguments": resp.model_dump_json(), + "arguments": resp.model_dump_json(indent=self.indent), }, }, ],