Skip to content
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

System prompt at App level #484

Merged
merged 4 commits into from
Sep 3, 2023
Merged

Conversation

Dev-Khant
Copy link
Collaborator

@Dev-Khant Dev-Khant commented Aug 25, 2023

Description

Add system_prompt on app level as well.

Fixes #452

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

Run poetry run pytest

  • Unit Test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

@Dev-Khant
Copy link
Collaborator Author

@cachho Can you please review it and help with documentation and also test for CustomApp.

"""
:param config: AppConfig instance to load as configuration. Optional.
:param system_prompt: Optional. System prompt string.
"""
if config is None:
config = AppConfig()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you just say

if system_prompt and not config.system_prompt:
    config.system_prompt = system_prompt

right here, and use latch on to the existing implementation? do this for all app classes? should be easier to maintain. You should make a setter method in config though, to make it cleaner.

Copy link
Collaborator Author

@Dev-Khant Dev-Khant Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are saying instead of using self.system_prompt we can set config.system_prompt for app classes. And add a setter method for system_prompt in config to set its value if we get prompt while app init. Right?? @cachho

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm saying that instead of introducing something new we just use the App __init__ to set the existing value in config, and keep working with that. As the most minimal way to achieve this.

My example should work, but introducing a set_system_prompt method in BaseAppConfig can be easier to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but why are we using BaseAppConfig when QueryConfig is used to get system_prompt on chat\query level. Using BaseAppConfig will take more changes and will be similar to current approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you aren't waiting for my input. I haven't had a chance to take a deeper look into this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was away for few days but I don't think making changes in BaseAppConfig will be a short approach. So directly using system_prompt from app _init_ seems to me the shortest approach. Let me know if you find any better or else I'll make few minor changes for it and PR will be ready for review @cachho

@Dev-Khant Dev-Khant marked this pull request as draft August 26, 2023 12:22
@Dev-Khant Dev-Khant marked this pull request as ready for review September 2, 2023 04:50
@Dev-Khant
Copy link
Collaborator Author

Done with changes

@taranjeet
Copy link
Member

looks good to me.

@taranjeet taranjeet merged commit ec9f454 into mem0ai:main Sep 3, 2023
0 of 3 checks passed
@Dev-Khant Dev-Khant deleted the system-prompt-App-level branch September 4, 2023 07:08
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.

Add support for system prompt at App level.
3 participants