Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back map for AIFunction #650

Merged
merged 7 commits into from
Nov 16, 2023
Merged

bring back map for AIFunction #650

merged 7 commits into from
Nov 16, 2023

Conversation

zzstoatzz
Copy link
Collaborator

and also ensures the thing we get back from decorating a function is an AIFunction not a partial of a wrapper of the function

this map implementation should be compatible with the existing tests

Example

In [1]: from marvin import ai_fn

In [2]: from typing_extensions import Literal

In [3]: Tag = Literal['bug', 'docs', 'enhancement']

In [4]: @ai_fn
   ...: def labels(content: str) -> set[Tag]:
   ...:     '''select an appropriate set of tags for the content'''
   ...:

In [5]: labels
Out[5]: AIFunction(fn=<function labels at 0x1096b0860>, environment=None, prompt='Your job is to generate likely outputs for a Python function with the\nfollowing signature and docstring:\n\n{{_source_code}}\n\nThe user will provide function inputs (if any) and you must respond with\nthe most likely result, which must be valid, double-quoted JSON.\n\nuser: The function was called with the following inputs:\n{%for (arg, value) in _arguments.items()%}\n- {{ arg }}: {{ value }}\n{% endfor %}\n\nWhat is its output?', name='FormatResponse', description='Formats the response.', field_name='data', field_description='The data to format.', render_kwargs={}, create=None)

In [6]: labels.map(["eek a bug in the docs", "i have an idea"])
Out[6]: [{'bug', 'docs'}, {'enhancement'}]

@zzstoatzz zzstoatzz merged commit 4415618 into main Nov 16, 2023
1 of 13 checks passed
@zzstoatzz zzstoatzz deleted the bring-back-map-for-ai-fn branch November 16, 2023 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants