Skip to content

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 requested review from aaazzam and jlowin November 16, 2023 18:17
@zzstoatzz zzstoatzz merged commit 4415618 into main Nov 16, 2023
@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.

3 participants