diff --git a/docs/prompting/prompt_function.md b/docs/prompting/prompt_function.md index a8d0617bc..43771747d 100644 --- a/docs/prompting/prompt_function.md +++ b/docs/prompting/prompt_function.md @@ -21,12 +21,12 @@ This is the easiest way to use Azure / OpenAI's function calling API. def list_fruits(n: int, color: str = 'red') -> list[str]: '''Generates a list of {{n}} {{color}} fruits''' - list_fruits(3, color = 'blue').serialize() + list_fruits(3, color = 'blue') ``` This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -84,12 +84,12 @@ This is the easiest way to use Azure / OpenAI's function calling API. def list_fruits(n: int, color: str = 'red') -> list[Fruit]: '''Generates a list of {{n}} {{color}} fruits''' - list_fruits(3, color = 'blue').serialize() + list_fruits(3, color = 'blue') ``` This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -168,12 +168,12 @@ This is the easiest way to use Azure / OpenAI's function calling API. def list_fruits(n: int, color: str = 'red') -> list[Fruit]: '''Generates a list of {{n}} {{color}} fruits''' - list_fruits(3, color = 'blue').serialize() + list_fruits(3, color = 'blue') ``` This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -246,12 +246,12 @@ This is the easiest way to use Azure / OpenAI's function calling API. def list_fruits(n: int, color: str = 'red') -> list[Fruit]: '''Generates a list of {{n}} {{color}} {{'{{ response_model.__name__.lower() }}'}}''' - list_fruits(3, color = 'blue').serialize() + list_fruits(3, color = 'blue') ``` This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -324,7 +324,7 @@ This is the easiest way to use Azure / OpenAI's function calling API. This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -385,7 +385,7 @@ This is the easiest way to use Azure / OpenAI's function calling API. This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```list_fruits(3, color = 'blue').serialize()```" + ??? success "Click to see results: ```list_fruits(3, color = 'blue')```" ```python { "messages": [ @@ -456,7 +456,7 @@ This is the easiest way to use Azure / OpenAI's function calling API. This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "Click to see results: ```classify_fruits('tomato').serialize()```" + ??? success "Click to see results: ```classify_fruits('tomato')```" ```python { "messages": [ @@ -525,7 +525,7 @@ This is the easiest way to use Azure / OpenAI's function calling API. This function can now be run and serialized to an Azure / OpenAI Function Calling payload. - ??? success "```extract_fruits('There are red apples and yellow bananas.').serialize()```" + ??? success "```extract_fruits('There are red apples and yellow bananas.')```" ```python { "messages": [ diff --git a/src/marvin/components/ai_classifier.py b/src/marvin/components/ai_classifier.py index af5af45dd..98e0a69d2 100644 --- a/src/marvin/components/ai_classifier.py +++ b/src/marvin/components/ai_classifier.py @@ -30,6 +30,7 @@ def ai_classifier_prompt( response_model_name="Index", response_model_description="The index of the most likely class.", response_model_field_name="index", + serialize_on_call=False, **kwargs, ) @@ -151,7 +152,7 @@ def get_prompt( ctx = ctx or cls.__metadata__.ctx or {} instructions = instructions or cls.__metadata__.instructions ctx["instructions"] = instructions or ctx.get("instructions", None) - return ai_classifier_prompt(cls, ctx=ctx, serialize_on_call=False, **kwargs) # type: ignore # noqa + return ai_classifier_prompt(cls, ctx=ctx, **kwargs) # type: ignore # noqa @classmethod def as_prompt( diff --git a/src/marvin/components/ai_function.py b/src/marvin/components/ai_function.py index 2188a64b5..81ec4cc7c 100644 --- a/src/marvin/components/ai_function.py +++ b/src/marvin/components/ai_function.py @@ -28,6 +28,7 @@ def ai_fn_prompt( @prompt_fn( ctx={"ctx": ctx or {}, "func": func, "inspect": inspect}, response_model=return_annotation, + serialize_on_call=False, **kwargs, ) def prompt_wrapper(*args: P.args, **kwargs: P.kwargs) -> None: # type: ignore # noqa @@ -81,7 +82,6 @@ def get_prompt( response_model_name=self.response_model_name, response_model_description=self.response_model_description, response_model_field_name=self.response_model_field_name, - serialize_on_call=False, ) def as_prompt( diff --git a/src/marvin/components/ai_model.py b/src/marvin/components/ai_model.py index 914887359..5ad28599e 100644 --- a/src/marvin/components/ai_model.py +++ b/src/marvin/components/ai_model.py @@ -33,6 +33,7 @@ def ai_model_prompt( response_model=cls, response_model_name="FormatResponse", response_model_description=description, + serialize_on_call=False, ) def prompt_wrapper(text: str) -> None: # type: ignore # noqa """ @@ -114,7 +115,6 @@ def get_prompt( response_model_name=response_model_name, response_model_description=response_model_description, response_model_field_name=response_model_field_name, - serialize_on_call=False, ) @classmethod