Closed stephenleo closed 2 weeks ago
fix is now released in v1.0.5
!
thanks for catching this :)
I actually just realized this fix only handled the case when specifically using the name kwargs
, but it's possible to name it anything (e.g. **call_kwargs
), so I've released an updated fix to handle this in v1.0.6
For example, the following should work now even with the updated **
naming:
from mirascope.core import openai, prompt_template
@openai.call("gpt-4o-mini")
@prompt_template("recommend a {genre} book")
def recommend_book(**whatever_i_want_to_call_this): ...
response = recommend_book(genre="fantasy")
print(response.content)
It works now. thanks!
Question
My prompt could take one of several values, and the function must be flexible in accepting the arguments required by each prompt.
Generally, I'd use **kwargs when the function arguments are not known in advance, but doing so throws an error.
It looks like Mirascope is looking for
{"genre": "science fiction"}
but using **kwargs makes the attrs{"kwargs": {"genre": "science fiction"}}
Minimal working example.
Error message: