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

Hizeros/feat add mem0 tutorial #898

Merged
merged 6 commits into from
Sep 7, 2024
Merged

Conversation

Hizeros
Copy link
Collaborator

@Hizeros Hizeros commented Sep 6, 2024

Summary by CodeRabbit

  • New Features

    • Added a new use case tutorial for building a chatbot using Mem0 and Streamlit.
    • Introduced a new README file for the Mem0 project, enhancing documentation and usability.
  • Improvements

    • Enhanced the PersonalHealingAssistant's interaction capabilities with a detailed SYSTEM_PROMPT for better emotional support and user engagement.
  • Bug Fixes

    • Minor formatting adjustments in logging messages for improved clarity.

Copy link

coderabbitai bot commented Sep 6, 2024

Walkthrough

The changes introduce a new tutorial for building a chatbot using "mem0" and Streamlit, enhancing the documentation with practical examples. A new README file for the mem0 project is also added, providing an overview and quick start guide. Additionally, modifications to the PersonalHealingAssistant class improve its emotional intelligence through a detailed system prompt, while minor adjustments are made to logging and comment formatting in existing files.

Changes

Files Change Summary
docs/_sidebar.md Added a link to a new use case for building a chatbot using mem0.
docs/use_cases/chatbot-integrated-mem0.md Introduced a tutorial for creating a personalized chatbot with mem0 and Streamlit.
example/mem0/README.md Created a new README outlining the purpose and quick start guide for the mem0 project.
example/mem0/app.py, example/mem0/core.py Minor adjustments in comments and a significant update to the PersonalHealingAssistant class with a new system prompt.
promptulate/utils/logger.py Minor formatting change in a logging message.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Chatbot
    participant MemoryClient

    User->>Chatbot: Ask question
    Chatbot->>MemoryClient: Retrieve memories
    MemoryClient-->>Chatbot: Provide relevant memories
    Chatbot->>User: Respond with personalized answer
Loading

🐰 In the meadow, bright and new,
A chatbot blooms with thoughts so true.
With mem0's magic, it learns and grows,
In every question, its wisdom flows.
So hop along, and give it a try,
A friend awaits, just ask and fly! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8ef7bad and 11a58f6.

Files ignored due to path filters (2)
  • docs/images/Mem0-Platform-Historical-mem-Records .png is excluded by !**/*.png
  • docs/images/chatbot-mem0.png is excluded by !**/*.png
Files selected for processing (6)
  • docs/_sidebar.md (1 hunks)
  • docs/use_cases/chatbot-integrated-mem0.md (1 hunks)
  • example/mem0/README.md (1 hunks)
  • example/mem0/app.py (1 hunks)
  • example/mem0/core.py (1 hunks)
  • promptulate/utils/logger.py (1 hunks)
Files skipped from review due to trivial changes (2)
  • docs/_sidebar.md
  • example/mem0/app.py
Additional context used
LanguageTool
example/mem0/README.md

[duplication] ~1-~1: Possible typo: you repeated a word
Context: # mem0 Mem0 (pronounced “mem-zero”) enhances AI ass...

(ENGLISH_WORD_REPEAT_RULE)

docs/use_cases/chatbot-integrated-mem0.md

[duplication] ~1-~1: Possible typo: you repeated a word
Context: # Build a chatbot using streamlit and mem0 Mem0 (pronounced “mem-zero”) enhances AI ass...

(ENGLISH_WORD_REPEAT_RULE)


[uncategorized] ~13-~13: You might be missing the article “the” here.
Context: ...treamlit_mem0` Next, let’s install all necessary libraries: ```shell pip install -U pro...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[typographical] ~165-~165: The word “Therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...can see that llm has read previous chat records,Therefore, it is possible to create personalized A...

(THUS_SENTENCE)

Ruff
promptulate/utils/logger.py

47-47: Line too long (91 > 88)

(E501)

example/mem0/core.py

5-5: Line too long (406 > 88)

(E501)


6-6: Line too long (160 > 88)

(E501)


7-7: Line too long (271 > 88)

(E501)


8-8: Line too long (307 > 88)

(E501)


9-9: Line too long (477 > 88)

(E501)


10-10: Line too long (401 > 88)

(E501)


11-11: Line too long (572 > 88)

(E501)


11-11: Trailing whitespace

Remove trailing whitespace

(W291)

Additional comments not posted (7)
example/mem0/README.md (3)

1-3: Introduction section is clear and effective.

The introduction effectively communicates the purpose and capabilities of mem0. The repetition of "mem0 Mem0" appears intentional and is not a typo.

Tools
LanguageTool

[duplication] ~1-~1: Possible typo: you repeated a word
Context: # mem0 Mem0 (pronounced “mem-zero”) enhances AI ass...

(ENGLISH_WORD_REPEAT_RULE)


5-5: Example description is informative.

The description provides a clear example of how mem0 can be utilized in a practical application.


9-32: Quick start guide is comprehensive and well-structured.

The quick start guide provides detailed, step-by-step instructions that are easy to follow, covering all necessary steps to get started with mem0.

docs/use_cases/chatbot-integrated-mem0.md (4)

1-3: Introduction Section Review

The introduction provides a clear and concise overview of the mem0 technology, its pronunciation, and its applications. This is well-written and sets a good context for the tutorial.

Tools
LanguageTool

[duplication] ~1-~1: Possible typo: you repeated a word
Context: # Build a chatbot using streamlit and mem0 Mem0 (pronounced “mem-zero”) enhances AI ass...

(ENGLISH_WORD_REPEAT_RULE)


9-11: Environment Setup: Conda Environment Creation

The command for creating a new conda environment is correctly formatted and appropriate for the setup. This ensures that users start with a clean environment specific to this project.


129-162: Running the Application

The instructions for running the application are clear and provide a straightforward path for users to follow from cloning the repository to running the app. The use of shell commands is appropriate and well-documented.


32-69: PersonalHealingAssistant Class Implementation

The implementation of the PersonalHealingAssistant class is comprehensive, covering initialization, memory management, and interaction methods. The use of MemoryClient and the handling of user inputs and responses are well implemented. However, ensure that the config parameter in the ask_question method is fully documented or explained elsewhere in the tutorial.

Comment on lines 47 to 48
"%(asctime)s | %(levelname)s | %(name)s:%(funcName)s:%(lineno)d - %(message)s",
# noqa
Copy link

Choose a reason for hiding this comment

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

Logging format adjustment is appropriate but consider line length.

The repositioning of the # noqa comment is appropriate. However, consider breaking the line to adhere to the line length standard.

Consider breaking the line to improve readability and adhere to coding standards:

-            "%(asctime)s | %(levelname)s | %(name)s:%(funcName)s:%(lineno)d - %(message)s",
+            "%(asctime)s | %(levelname)s | %(name)s:%(funcName)s:%(lineno)d - "
+            "%(message)s",
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"%(asctime)s | %(levelname)s | %(name)s:%(funcName)s:%(lineno)d - %(message)s",
# noqa
"%(asctime)s | %(levelname)s | %(name)s:%(funcName)s:%(lineno)d - "
"%(message)s",
# noqa
Tools
Ruff

47-47: Line too long (91 > 88)

(E501)

Comment on lines 4 to 13
SYSTEM_PROMPT = """
You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.
1. ** Identify and record emotions **: You will identify emotions in users 'responses and guide users to describe their emotions and what they have experienced.
2. ** Empathic reply **: You show real interest in the user's experience, always show respect and understanding, and express empathy and acceptance in a gentle and cordial way. When showing empathy, you will use poetic language and metaphor to retell the user's feelings.
3. ** Provide companionship and comfort value **: When negative emotions are identified in the user's answer, comfort and encourage the user, you will tell the user,"I will be here with you","Don't be afraid, you will be free" and other warm words, don't use the same comforting words repeatedly every time.
4. ** Guide self-reflection **: You will ask a question at the end of each message to encourage users to reflect deeply on their emotions ** and thoughts. You will ask thoughtful questions, such as "Why do you think that?" and "Where do you feel the source of your emotions?", triggering self-reflection among users. When replying each time, limit the questions to 1-2, and use "or say" to change the answer to complex questions. Avoid making lists and never end conversations.
5. After the user tells an incident and his emotional reaction, do not repeatedly ask questions about the details of the incident. You will encourage users to write their reflections in their diary, or ask users what else they think about and make interesting discoveries today, such as "I'm glad you are willing to share your emotions with me. Have you thought about any interesting topics today?"“。
6. You will obtain the user's historical chat history. Under appropriate circumstances, you can use the diary content to understand the user's status and guide the user to reflect or recognize their own emotions. For example, if a user wrote in his diary yesterday,"I feel very anxious about doing a project," then when the user initiates a chat with you for the first time today, you can ask,"Have you solved the project problem today?" Will you still feel anxious about project problems?" or "Can I hear why you feel anxious about doing a project?" and other questions.
7. Decide which language to reply to the user based on the language entered by the user
"""
Copy link

Choose a reason for hiding this comment

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

Significant enhancement to the assistant's capabilities.

The new SYSTEM_PROMPT significantly enhances the assistant's emotional intelligence and conversational capabilities. However, consider addressing the line length issues to improve code readability and maintainability.

Consider breaking the long lines into shorter segments to adhere to coding standards. For example:

- You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.
+ You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.

Committable suggestion was skipped due to low confidence.

Tools
Ruff

5-5: Line too long (406 > 88)

(E501)


6-6: Line too long (160 > 88)

(E501)


7-7: Line too long (271 > 88)

(E501)


8-8: Line too long (307 > 88)

(E501)


9-9: Line too long (477 > 88)

(E501)


10-10: Line too long (401 > 88)

(E501)


11-11: Line too long (572 > 88)

(E501)


11-11: Trailing whitespace

Remove trailing whitespace

(W291)

Comment on lines +25 to +26
import pne
from mem0 import MemoryClient
Copy link

Choose a reason for hiding this comment

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

Import Statements in core.py

The import statement for pne is unclear as it's not a well-known library. Ensure that pne is either explained earlier in the document or add a comment explaining what it is used for.

Suggest adding a comment for clarity:

+import pne  # Pne is used for [purpose/explanation]
 from mem0 import MemoryClient

Committable suggestion was skipped due to low confidence.

Comment on lines +165 to +166
You can see that llm has read previous chat records,Therefore, it is possible to create personalized AI assistants for different users
![Mem0-Platform-Historical-mem-Records ](../images/Mem0-Platform-Historical-mem-Records%20.png)
Copy link

Choose a reason for hiding this comment

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

Typographical Issue in Running Effect Description

The sentence structure in the running effect description is awkward due to the improper use of "Therefore" without a preceding comma.

Suggest correcting the typographical error:

-You can see that llm has read previous chat records,Therefore, it is possible to create personalized AI assistants for different users
+You can see that llm has read previous chat records, therefore, it is possible to create personalized AI assistants for different users.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
You can see that llm has read previous chat records,Therefore, it is possible to create personalized AI assistants for different users
![Mem0-Platform-Historical-mem-Records ](../images/Mem0-Platform-Historical-mem-Records%20.png)
You can see that llm has read previous chat records, therefore, it is possible to create personalized AI assistants for different users.
![Mem0-Platform-Historical-mem-Records ](../images/Mem0-Platform-Historical-mem-Records%20.png)
Tools
LanguageTool

[typographical] ~165-~165: The word “Therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...can see that llm has read previous chat records,Therefore, it is possible to create personalized A...

(THUS_SENTENCE)

Comment on lines +13 to +17
Next, let’s install all necessary libraries:

```shell
pip install -U promptulate streamlit mem0ai
```
Copy link

Choose a reason for hiding this comment

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

Library Installation Command

The pip install command is clear and includes the necessary libraries. However, consider specifying versions for the libraries to ensure compatibility and prevent potential issues with future library updates.

Suggest specifying library versions:

-pip install -U promptulate streamlit mem0ai
+pip install promptulate==1.0.0 streamlit==1.0.0 mem0ai==1.0.0

Committable suggestion was skipped due to low confidence.

Tools
LanguageTool

[uncategorized] ~13-~13: You might be missing the article “the” here.
Context: ...treamlit_mem0` Next, let’s install all necessary libraries: ```shell pip install -U pro...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Comment on lines +78 to +125
import pne
import streamlit as st
from core import PersonalHealingAssistant


def main():
config = pne.beta.st.model_sidebar()
with st.sidebar:
mem0_user_id = st.text_input("mem0 user id", type="password")
mem0_api_key = st.text_input(
"mem0 API Key", key="provider_mem0_api_key", type="password"
)

st.title("PersonalHealingAssistant")
st.caption(
"""
Personal Healing Assistant combines pne and mem0ai to create a personalized healing assistant for you \n
🚀 Power by [promptulate](https://github.com/Undertone0809/promptulate)
""" # noqa
)
st.chat_message("assistant").write(
"I am your personal healing assistant, how can I help you? "
)

ai_assistant = PersonalHealingAssistant()

if prompt := st.chat_input("Please enter what you want to know "):
if not config.api_key:
st.info("Please add your model API key to continue.")
st.stop()

if not mem0_api_key:
st.error("Please provide your mem0 API Key to continue.")
st.stop()

ai_assistant.set_mem0_api_key(mem0_api_key)

answer = ai_assistant.ask_question(
question=prompt, user_id=mem0_user_id, config=config
)

st.chat_message("user").write(prompt)
st.chat_message("assistant").write_stream(answer)


if __name__ == "__main__":
main()
```
Copy link

Choose a reason for hiding this comment

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

Streamlit App Implementation in app.py

The Streamlit app setup and interaction flow are well structured. The use of st.sidebar for input collection and the main function's control flow are clear. However, the error handling for missing API keys could be improved by providing more specific messages or guidance on where to obtain these keys.

Suggest improving error messages for better user guidance:

-if not config.api_key:
+if not config.api_key:
+    st.info("API key is missing. Please obtain an API key from [source] to continue.")
-if not mem0_api_key:
+if not mem0_api_key:
+    st.error("mem0 API Key is missing. Please obtain a mem0 API Key from [source] to continue.")

Committable suggestion was skipped due to low confidence.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 11a58f6 and 391ddac.

Files selected for processing (1)
  • example/mem0/core.py (1 hunks)
Additional comments not posted (1)
example/mem0/core.py (1)

14-19: Verify integration of SYSTEM_PROMPT and review class methods.

The SYSTEM_PROMPT is integrated into the messages list during the initialization of PersonalHealingAssistant. This is a crucial change as it sets the tone for all interactions handled by this class. Ensure that this integration is tested thoroughly to confirm that the prompt is correctly used in conversations.

Additionally, review the methods related to memory handling and chat interactions to ensure they are robust and handle errors gracefully. Consider adding error handling for network issues or API failures, especially in methods that interact with external services like MemoryClient and pne.chat.

Also applies to: 19-19

Verification successful

Integration of SYSTEM_PROMPT is correct and functional.

The SYSTEM_PROMPT is effectively integrated into the PersonalHealingAssistant class. It is used as the initial context for chat interactions, and the message history is maintained throughout the interaction. The ask_question method appropriately handles the chat flow by appending user and assistant messages, ensuring that the context set by SYSTEM_PROMPT is preserved. No issues were found with this integration.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `SYSTEM_PROMPT` in chat interactions.

# Test: Search for the usage of `SYSTEM_PROMPT` in chat interactions. Expect: Proper handling and usage in the flow.
rg --type python -A 5 $'SYSTEM_PROMPT'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `SYSTEM_PROMPT` in chat interactions.

# Test: Search for the usage of `SYSTEM_PROMPT` in chat interactions. Expect: Proper handling and usage in the flow.
rg --type py -A 5 $'SYSTEM_PROMPT'

Length of output: 18814


Script:

#!/bin/bash
# Description: Verify how `self.messages` is used in `example/mem0/core.py` to ensure `SYSTEM_PROMPT` is utilized correctly.

# Test: Search for the usage of `self.messages` in `example/mem0/core.py`.
rg --type py 'self\.messages' -A 5

Length of output: 4053

Comment on lines +4 to +13
SYSTEM_PROMPT = """
You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.
1. ** Identify and record emotions **: You will identify emotions in users 'responses and guide users to describe their emotions and what they have experienced.
2. ** Empathic reply **: You show real interest in the user's experience, always show respect and understanding, and express empathy and acceptance in a gentle and cordial way. When showing empathy, you will use poetic language and metaphor to retell the user's feelings.
3. ** Provide companionship and comfort value **: When negative emotions are identified in the user's answer, comfort and encourage the user, you will tell the user,"I will be here with you","Don't be afraid, you will be free" and other warm words, don't use the same comforting words repeatedly every time.
4. ** Guide self-reflection **: You will ask a question at the end of each message to encourage users to reflect deeply on their emotions ** and thoughts. You will ask thoughtful questions, such as "Why do you think that?" and "Where do you feel the source of your emotions?", triggering self-reflection among users. When replying each time, limit the questions to 1-2, and use "or say" to change the answer to complex questions. Avoid making lists and never end conversations.
5. After the user tells an incident and his emotional reaction, do not repeatedly ask questions about the details of the incident. You will encourage users to write their reflections in their diary, or ask users what else they think about and make interesting discoveries today, such as "I'm glad you are willing to share your emotions with me. Have you thought about any interesting topics today?"“。
6. You will obtain the user's historical chat history. Under appropriate circumstances, you can use the diary content to understand the user's status and guide the user to reflect or recognize their own emotions. For example, if a user wrote in his diary yesterday,"I feel very anxious about doing a project," then when the user initiates a chat with you for the first time today, you can ask,"Have you solved the project problem today?" Will you still feel anxious about project problems?" or "Can I hear why you feel anxious about doing a project?" and other questions.
7. Decide which language to reply to the user based on the language entered by the user
""" # noqa
Copy link

Choose a reason for hiding this comment

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

Refactor SYSTEM_PROMPT for readability and maintainability.

The SYSTEM_PROMPT variable contains several lines that exceed the typical length limit for code readability (88 characters). This can make the code hard to read and maintain. Consider breaking these lines into shorter segments to adhere to coding standards. Additionally, ensure that the markdown syntax within the string is correctly formatted to avoid rendering issues in the output.

Here's a suggested refactor for better readability:

- You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.
+ You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, and gentle when talking to users. You do not provide advice but help users explore their emotions and feelings by asking clever questions. This approach facilitates in-depth conversations and maintains a good chat atmosphere. Avoid using personal pronouns other than "you".
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SYSTEM_PROMPT = """
You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, gentle when talking to users, and do not provide advice. You will help users explore their emotions and feelings by asking clever questions, so that you can go directly into in-depth conversations and always maintain a good chat atmosphere. Except for "you", you don't call each other.
1. ** Identify and record emotions **: You will identify emotions in users 'responses and guide users to describe their emotions and what they have experienced.
2. ** Empathic reply **: You show real interest in the user's experience, always show respect and understanding, and express empathy and acceptance in a gentle and cordial way. When showing empathy, you will use poetic language and metaphor to retell the user's feelings.
3. ** Provide companionship and comfort value **: When negative emotions are identified in the user's answer, comfort and encourage the user, you will tell the user,"I will be here with you","Don't be afraid, you will be free" and other warm words, don't use the same comforting words repeatedly every time.
4. ** Guide self-reflection **: You will ask a question at the end of each message to encourage users to reflect deeply on their emotions ** and thoughts. You will ask thoughtful questions, such as "Why do you think that?" and "Where do you feel the source of your emotions?", triggering self-reflection among users. When replying each time, limit the questions to 1-2, and use "or say" to change the answer to complex questions. Avoid making lists and never end conversations.
5. After the user tells an incident and his emotional reaction, do not repeatedly ask questions about the details of the incident. You will encourage users to write their reflections in their diary, or ask users what else they think about and make interesting discoveries today, such as "I'm glad you are willing to share your emotions with me. Have you thought about any interesting topics today?"
6. You will obtain the user's historical chat history. Under appropriate circumstances, you can use the diary content to understand the user's status and guide the user to reflect or recognize their own emotions. For example, if a user wrote in his diary yesterday,"I feel very anxious about doing a project," then when the user initiates a chat with you for the first time today, you can ask,"Have you solved the project problem today?" Will you still feel anxious about project problems?" or "Can I hear why you feel anxious about doing a project?" and other questions.
7. Decide which language to reply to the user based on the language entered by the user
""" # noqa
SYSTEM_PROMPT = """
You are a listener, and your task is to help users sort out their emotions and thoughts. You are friendly, approachable, and gentle when talking to users. You do not provide advice but help users explore their emotions and feelings by asking clever questions. This approach facilitates in-depth conversations and maintains a good chat atmosphere. Avoid using personal pronouns other than "you".
1. ** Identify and record emotions **: You will identify emotions in users 'responses and guide users to describe their emotions and what they have experienced.
2. ** Empathic reply **: You show real interest in the user's experience, always show respect and understanding, and express empathy and acceptance in a gentle and cordial way. When showing empathy, you will use poetic language and metaphor to retell the user's feelings.
3. ** Provide companionship and comfort value **: When negative emotions are identified in the user's answer, comfort and encourage the user, you will tell the user,"I will be here with you","Don't be afraid, you will be free" and other warm words, don't use the same comforting words repeatedly every time.
4. ** Guide self-reflection **: You will ask a question at the end of each message to encourage users to reflect deeply on their emotions ** and thoughts. You will ask thoughtful questions, such as "Why do you think that?" and "Where do you feel the source of your emotions?", triggering self-reflection among users. When replying each time, limit the questions to 1-2, and use "or say" to change the answer to complex questions. Avoid making lists and never end conversations.
5. After the user tells an incident and his emotional reaction, do not repeatedly ask questions about the details of the incident. You will encourage users to write their reflections in their diary, or ask users what else they think about and make interesting discoveries today, such as "I'm glad you are willing to share your emotions with me. Have you thought about any interesting topics today?""
6. You will obtain the user's historical chat history. Under appropriate circumstances, you can use the diary content to understand the user's status and guide the user to reflect or recognize their own emotions. For example, if a user wrote in his diary yesterday,"I feel very anxious about doing a project," then when the user initiates a chat with you for the first time today, you can ask,"Have you solved the project problem today?" Will you still feel anxious about project problems?" or "Can I hear why you feel anxious about doing a project?" and other questions.
7. Decide which language to reply to the user based on the language entered by the user
""" # noqa

Copy link
Owner

@Undertone0809 Undertone0809 left a comment

Choose a reason for hiding this comment

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

lgtm

@Undertone0809 Undertone0809 merged commit cd31d04 into main Sep 7, 2024
25 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 8, 2024
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.

2 participants