Skip to content

Commit

Permalink
Merge pull request #328 from PrefectHQ/refactor-ai_fn-prompt-outside-…
Browse files Browse the repository at this point in the history
…of-run

move out prompt generation from _run to own _method
  • Loading branch information
zzstoatzz authored May 26, 2023
2 parents a095fee + 440fbb7 commit 36368d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/marvin/ai_functions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __call__(self, *args, **kwargs):

return output

async def _run(self, *args, **kwargs):
async def __prompt__(self, *args, **kwargs):
# Get function signature
sig = inspect.signature(self.fn)

Expand All @@ -178,7 +178,10 @@ async def _run(self, *args, **kwargs):
input_binds=bound_args.arguments,
yield_value=yield_value,
)
return message

async def _run(self, *args, **kwargs):
message = await self.__prompt__(*args, **kwargs)
bot = self.get_bot()
response = await bot.say(message)
return response.parsed_content
Expand Down

0 comments on commit 36368d0

Please sign in to comment.