diff --git a/docs/docs/text/extraction.md b/docs/docs/text/extraction.md index 5d0fbbd26..f9af36919 100644 --- a/docs/docs/text/extraction.md +++ b/docs/docs/text/extraction.md @@ -142,13 +142,13 @@ Sometimes the cast operation is obvious, as in the "big apple" example above. Ot In a simple case, instructions can be used independent of any type-casting. Here, we want to keep the output a string, but get the 2-letter abbreviation of the state. ```python -marvin.cast('California', to=str, instruction="The state's abbreviation") +marvin.cast('California', to=str, instructions="The state's abbreviation") # "CA" -marvin.cast('The sunshine state', to=str, instruction="The state's abbreviation") +marvin.cast('The sunshine state', to=str, instructions="The state's abbreviation") # "FL" -marvin.cast('Mass.', to=str, instruction="The state's abbreviation") +marvin.cast('Mass.', to=str, instructions="The state's abbreviation") # MA ``` diff --git a/docs/docs/text/transformation.md b/docs/docs/text/transformation.md index b40c57bd4..5e532bd2a 100644 --- a/docs/docs/text/transformation.md +++ b/docs/docs/text/transformation.md @@ -56,13 +56,13 @@ Sometimes the cast operation is obvious, as in the "big apple" example above. Ot In a simple case, instructions can be used independent of any type-casting. Here, we want to keep the output a string, but get the 2-letter abbreviation of the state. ```python -marvin.cast('California', target=str, instruction="The state's abbreviation") +marvin.cast('California', target=str, instructions="The state's abbreviation") # "CA" -marvin.cast('The sunshine state', target=str, instruction="The state's abbreviation") +marvin.cast('The sunshine state', target=str, instructions="The state's abbreviation") # "FL" -marvin.cast('Mass.', target=str, instruction="The state's abbreviation") +marvin.cast('Mass.', target=str, instructions="The state's abbreviation") # MA ``` diff --git a/docs/examples/michael_scott_business/michael_scott.jpg b/docs/examples/michael_scott_business/michael_scott.jpg new file mode 100644 index 000000000..4a1c93d34 Binary files /dev/null and b/docs/examples/michael_scott_business/michael_scott.jpg differ diff --git a/docs/examples/michael_scott_business/michael_scott_business.md b/docs/examples/michael_scott_business/michael_scott_business.md new file mode 100644 index 000000000..2028fd0e3 --- /dev/null +++ b/docs/examples/michael_scott_business/michael_scott_business.md @@ -0,0 +1,25 @@ +# Michael Scott's four kinds of businesses + +![](michael_scott.jpg) + + +!!! example "What kind of business are LLMs?" + ```python + import marvin + + businesses = [ + "tourism", + "food service", + "railroads", + "sales", + "hospitals/manufacturing", + "air travel", + ] + + result = marvin.classify("LLMs", labels=businesses) + ``` + + !!! success "Tourism" + ```python + assert result == "tourism" + ``` \ No newline at end of file diff --git a/docs/examples/xkcd_bird.md b/docs/examples/xkcd_bird.md new file mode 100644 index 000000000..60258e8fc --- /dev/null +++ b/docs/examples/xkcd_bird.md @@ -0,0 +1,24 @@ +# xkcd's bird photo classifier + +[![](https://imgs.xkcd.com/comics/tasks.png)](https://xkcd.com/1425/) + + +!!! example "Is this a bird?" + [![](https://images.unsplash.com/photo-1613891188927-14c2774fb8d7)](https://unsplash.com/photos/green-and-black-humming-bird-eLC1Bd3PLu4) + ```python + import marvin + + photo = marvin.beta.Image( + "https://images.unsplash.com/photo-1613891188927-14c2774fb8d7", + ) + + result = marvin.beta.classify( + photo, + labels=["bird", "not bird"] + ) + ``` + + !!! success "Yes!" + ```python + assert result == "bird" + ``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 95eeb2222..a30c4664b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -79,6 +79,10 @@ nav: - Slackbot: examples/slackbot.md - Python augmented prompts: examples/python_augmented_prompts.md - Being specific about types: examples/being_specific_about_types.md + - Examples: + - examples/xkcd_bird.md + - examples/michael_scott_business/michael_scott_business.md + - Community: - community/index.md diff --git a/src/marvin/beta/applications/applications.py b/src/marvin/beta/applications/applications.py index c237c3065..aa251889d 100644 --- a/src/marvin/beta/applications/applications.py +++ b/src/marvin/beta/applications/applications.py @@ -69,13 +69,10 @@ def get_tools(self) -> list[AssistantTool]: if not isinstance(tool, Tool): kwargs = None signature = inspect.signature(tool) - parameter = None for parameter in signature.parameters.values(): if parameter.annotation == Application: + kwargs = {parameter.name: self} break - if parameter is not None: - kwargs = {parameter.name: self} - tool = tool_from_function(tool, kwargs=kwargs) tools.append(tool)