feat(generators): introduce personas and extended context for UserSimulator#2249
Conversation
Summary of ChangesHello @davidberenstein1957, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a PersonaSimulator for simulating user interactions, complete with a Jinja2 template for prompt generation and a comprehensive test suite. The implementation is well-structured and robust. I've suggested a couple of minor improvements to add validation to the pydantic model fields for persona and max_steps to make the class even more robust against invalid inputs.
- Added PersonaSimulator class to simulate user interactions with predefined or custom personas. - Implemented output structure for client descriptions and conversation management. - Created a Jinja2 template for persona instructions and context handling. - Added tests to validate functionality and ensure consistent client descriptions across conversation turns.
58d59eb to
5b11f86
Compare
- Added minimum length validation for the persona field to ensure a valid input. - Updated max_steps field to enforce a non-negative integer constraint.
|
@kevinmessiaen @henchaves, I feel this also introduces some discussion on how to pass along and re-use information from We could pass some class information along by default as metadata, or we can configure something more robust. Happy to hear your thoughts. |
… functions - Replaced individual persona tests with a parameterized test for better coverage and maintainability. - Added helper functions to create mock responses and advance generator turns. - Implemented validation tests for empty persona and negative max_steps scenarios. - Ensured consistent client description handling across conversation turns.
…lasses-userresponder-personaresponder
…lasses-userresponder-personaresponder
…onas - Simplified the PersonaSimulator class documentation to emphasize custom persona descriptions. - Removed predefined persona examples from the documentation and template logic, allowing for more flexible persona usage. - Updated test cases to reflect changes in persona handling, ensuring clarity in context and description parameters.
…ation - Removed client description handling from the PersonaSimulator, simplifying its logic and focusing on predefined and custom personas. - Updated the Jinja2 template to utilize predefined personas directly, enhancing clarity in persona simulation. - Revised test cases to reflect the removal of client description, ensuring accurate testing of persona message generation.
@davidberenstein1957 I not sure to understand the issue with Regarding reusing the persona, I feel like the simpliest fix would be to allow describe a reusable persona and create simulators from persona. helpfull_persona = Persona("helpful_user", ...) # Persona only hold information on how to generate message, not the what to generate
simulator_1 = helpfull_persona.simulator("Describe your problem installing giskard v3", max_turn=3)
simulator_2 = helpfull_persona.simulator("Say that you tried the solution but you get resolution error, you are using python 3.10", max_turn=3)
# Change persona dynamically (assume inside a scenario
simulator_3 = Persona("thankfull_user", ...) .simulator("State that it's working now with python 3.13", max_turn=1) |
- Deleted the PersonaSimulator class and its associated files, streamlining the generator structure. - Updated UserSimulator to incorporate persona handling directly, enhancing its functionality. - Revised Jinja2 templates for user simulation to reflect the removal of PersonaSimulator. - Adjusted tests to ensure proper functionality of UserSimulator with the new persona integration.
- Deleted the PersonaSimulator class and its associated files, streamlining the generator structure. - Updated UserSimulator to incorporate persona handling directly, enhancing its functionality. - Revised Jinja2 templates for user simulation to reflect the removal of PersonaSimulator. - Adjusted tests to ensure proper functionality of UserSimulator with the new persona integration.
…dling - Removed unused advance_turn helper function to streamline test code. - Enhanced test cases to validate message generation and persona integration in UserSimulator. - Introduced a new helper function to wrap text in XML tags for better output formatting. - Adjusted assertions to ensure accurate tracking of generator calls and interactions.
…lasses-userresponder-personaresponder
kevinmessiaen
left a comment
There was a problem hiding this comment.
Looking good to me, just some small comments
| Parameters | ||
| ---------- | ||
| persona : str | ||
| Predefined persona name or custom persona description |
There was a problem hiding this comment.
It's not documented what are the predefined persona. It would be nice to provide the list in the docstring
| persona: str = Field( | ||
| ..., description="Predefined persona name or custom description", min_length=1 | ||
| ) |
There was a problem hiding this comment.
While it's concise to have a single str field I'm fearing of potential issues:
- Typos won't be noticed:
persona=helpfull_userorpersona=helpful-userwill work without error, but the instruction in the prompt won't be what we expect them to be - No error if a persona has been removed/deleted (even if we should not make breaking changes, if this happens it will be easy to miss this)
Shall we have an enum of persona?
class Persona(StrEnum):
HelpfulUser = "helful_user"
...
# In the UserSimulator class
persona: Persona | str = Field(...)
# Then we can instaciate persona safely
UserSimulator(persona=Persona.HelpfulUser)
UserSimulator(persona="helful_user") # Will act as Persona.HelpfulUser but without type safety
UserSimulator(persona="You are an angry customer") # Custom promptThis would also help fixing the documentation issue, as it'll be possible to explore personas with autocompletion/autodoc
…lasses-userresponder-personaresponder
Description
closes #ENG-1388
Related Issue
Type of Change
Checklist
CODE_OF_CONDUCT.mddocument.CONTRIBUTING.mdguide.pdm.lockrunningpdm update-lock(only applicable whenpyproject.tomlhas beenmodified)