-
Notifications
You must be signed in to change notification settings - Fork 303
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
Adds dynamic to system_prompt decorator, allowing reevaluation #560
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, but you need to format code and fix linting issues.
@@ -526,16 +526,37 @@ def system_prompt(self, func: Callable[[], str], /) -> Callable[[], str]: ... | |||
@overload | |||
def system_prompt(self, func: Callable[[], Awaitable[str]], /) -> Callable[[], Awaitable[str]]: ... | |||
|
|||
@overload | |||
def system_prompt( | |||
self, func: _system_prompt.SystemPromptFunc[AgentDeps] | None = None, /, *, dynamic: bool = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this overload can't have func
, so the signature is just (self, *, dynamic: bool = False)
@@ -830,8 +855,8 @@ async def add_tool(tool: Tool[AgentDeps]) -> None: | |||
) | |||
|
|||
async def _prepare_messages( | |||
self, user_prompt: str, message_history: list[_messages.ModelMessage] | None, run_context: RunContext[AgentDeps] | |||
) -> list[_messages.ModelMessage]: | |||
self, user_prompt: str, message_history: list[_messages.ModelMessage] | None, run_context: RunContext[AgentDeps] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should have changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, format on save is on.
tests/test_agent.py
Outdated
] | ||
) | ||
|
||
def test_messages_history_reevaluate_system_prompt_dirty(set_event_loop: None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what these tests are testing.
Please add a doctring, but also I think there are more tests here than really necessary.
Co-authored-by: Samuel Colvin <[email protected]>
@samuelcolvin I'm reviewing this, since I found a bug, when using dynamic=True on one decorator it reevaluates (builds) all other sys_parts. I will have to make a discrimination or annotate the message once is built. |
Hey @josead |
I will commit Tomorrow, but yes I have an approach
El mar, 31 de dic de 2024, 7:59 p. m., Hamza Farhan <
***@***.***> escribió:
… Hey @josead <https://github.com/josead>
Were you able to solve the issue?
—
Reply to this email directly, view it on GitHub
<#560 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABM4XWN43HEPZTA3E7AFMDT2IMOUZAVCNFSM6AAAAABUKEBRB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRWG42DIOBXHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Adds optional parameter "dynamic" to decorator "system_prompt".
Implements the reevaluation of system prompts.
Allows new prompts to be added only if they are dynamic.
Hello Pydantic Team,
In response to this issue I've created #531
Let me know if this is a good approach for the enhancement.
CC: @samuelcolvin @sydney-runkle
Regards!