Skip to content

Commit

Permalink
Merge branch 'main' into base-url
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz authored Jan 19, 2024
2 parents 086e9a5 + b521314 commit 67f0e62
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/docs/text/extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/text/transformation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions docs/examples/michael_scott_business/michael_scott_business.md
Original file line number Diff line number Diff line change
@@ -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"
```
24 changes: 24 additions & 0 deletions docs/examples/xkcd_bird.md
Original file line number Diff line number Diff line change
@@ -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"
```
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/marvin/beta/applications/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 67f0e62

Please sign in to comment.