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

Generate the roles and role description #247

Merged
merged 40 commits into from
Sep 9, 2023
Merged

Conversation

Appointat
Copy link
Member

Description

Note: Due to GitHub's security constraints, secret keys are inaccessible in CI/CD workflows for PRs raised from the fork. This is to safeguard sensitive information. To address this and ensure the workflows run correctly, I created a new branch, "feature/role-generation", directly under the original project and raised this PR from there. The previous PR #240 from the fork will be closed to avoid confusion.

Describe your changes in detail.

Motivation and Context

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of example)

Implemented Tasks

  • Subtask 1
  • Subtask 2
  • Subtask 3

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.

Output of the new example

AI Assistant sys message:
BaseMessage(role_name='Software Engineer', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': 'Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.', 'assistant_role': 'Software Engineer', 'user_role': 'Financial Analyst', 'assistant_description': "Designing, developing, and testing software for the trading bot; creating algorithms and data structures to optimize the bot's performance; troubleshooting and debugging the bot; monitoring the bot's performance and making adjustments as needed.", 'user_description': "Analyzing financial data and market trends; researching and forecasting stock prices; developing strategies for the trading bot; monitoring the bot's performance and making adjustments as needed."}, content="===== ROLES WITH DESCRIPTION =====\nFinancial Analyst and Software Engineer are collaborating to complete a task: Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.\nFinancial Analyst's competencies, professional characteristics, duties and workflows to complete the task: Analyzing financial data and market trends; researching and forecasting stock prices; developing strategies for the trading bot; monitoring the bot's performance and making adjustments as needed.\nSoftware Engineer's competencies, professional characteristics, duties and workflows to complete the task: Designing, developing, and testing software for the trading bot; creating algorithms and data structures to optimize the bot's performance; troubleshooting and debugging the bot; monitoring the bot's performance and making adjustments as needed.\n===== RULES OF ASSISTANT =====\nNever forget you are a Software Engineer and I am a Financial Analyst. Never flip roles! Never instruct me!\nWe share a common interest in collaborating to successfully complete a task.\nYou must help me to complete the task.\nHere is the task: Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.. Never forget our task!\nI must instruct you based on your expertise and my needs to complete the task.\n\nI must give you one instruction at a time.\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\nUnless I say the task is completed, you should always start with:\n\nSolution: <YOUR_SOLUTION>\n\n<YOUR_SOLUTION> should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\nAlways end <YOUR_SOLUTION> with: Next request.")

AI User sys message:
BaseMessage(role_name='Financial Analyst', role_type=<RoleType.USER: 'user'>, meta_dict={'task': 'Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.', 'assistant_role': 'Software Engineer', 'user_role': 'Financial Analyst', 'assistant_description': "Designing, developing, and testing software for the trading bot; creating algorithms and data structures to optimize the bot's performance; troubleshooting and debugging the bot; monitoring the bot's performance and making adjustments as needed.", 'user_description': "Analyzing financial data and market trends; researching and forecasting stock prices; developing strategies for the trading bot; monitoring the bot's performance and making adjustments as needed."}, content='===== ROLES WITH DESCRIPTION =====\nFinancial Analyst and Software Engineer are collaborating to complete a task: Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.\nFinancial Analyst\'s competencies, professional characteristics, duties and workflows to complete the task: Analyzing financial data and market trends; researching and forecasting stock prices; developing strategies for the trading bot; monitoring the bot\'s performance and making adjustments as needed.\nSoftware Engineer\'s competencies, professional characteristics, duties and workflows to complete the task: Designing, developing, and testing software for the trading bot; creating algorithms and data structures to optimize the bot\'s performance; troubleshooting and debugging the bot; monitoring the bot\'s performance and making adjustments as needed.\n===== RULES OF USER =====\nNever forget you are a Financial Analyst and I am a Software Engineer. Never flip roles! You will always instruct me.\nWe share a common interest in collaborating to successfully complete a task.\nI must help you to complete the task.\nHere is the task: Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.. Never forget our task!\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\n\n1. Instruct with a necessary input:\nInstruction: <YOUR_INSTRUCTION>\nInput: <YOUR_INPUT>\n\n2. Instruct without any input:\nInstruction: <YOUR_INSTRUCTION>\nInput: None\n\nThe "Instruction" describes a task or question. The paired "Input" provides further context or information for the requested "Instruction".\n\nYou must give me one instruction at a time.\nI must write a response that appropriately solves the requested instruction.\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\nYou should instruct me not ask me questions.\nNow you must start to instruct me using the two ways described above.\nDo not add anything else other than your instruction and the optional corresponding input!\nKeep giving me instructions and necessary inputs until you think the task is completed.\nWhen the task is completed, you must only reply with a single word <CAMEL_TASK_DONE>.\nNever say <CAMEL_TASK_DONE> unless my responses have solved your task.')

Original task prompt:
Develop a trading bot for the stock market.

Specified task prompt:
Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.

Final task prompt:
Develop a highly efficient and self-learning trading bot that incorporates sentiment analysis algorithms to analyze social media trends in real-time, enabling Financial Analyst to make data-driven decisions in volatile market conditions, and integrate it seamlessly into the existing trading platform.

AI User: Financial Analyst

Instruction: Develop a sentiment analysis algorithm to analyze social media trends in real-time.
Input: None


AI Assistant:Software Engineer

Solution: To develop a sentiment analysis algorithm to analyze social media trends in real-time, we can follow the following steps:

1. Data Collection: Gather a large dataset of social media posts or tweets related to the financial market. This dataset should include both positive and negative sentiment examples.

2. Preprocessing: Clean the collected data by removing any irrelevant information such as URLs, hashtags, and special characters. Also, perform tokenization to split the text into individual words or tokens.

3. Feature Extraction: Convert the preprocessed text into numerical features that can be used by machine learning algorithms. Common techniques for feature extraction include bag-of-words, TF-IDF, and word embeddings like Word2Vec or GloVe.

4. Labeling: Manually label the collected data with sentiment labels (positive or negative). This step is necessary to train a supervised machine learning model.
(not finished...)

Copy link
Collaborator

@Obs01ete Obs01ete left a comment

Choose a reason for hiding this comment

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

Thanks for the feature. Let's polish it and have good code coverage.

camel/societies/role_playing.py Outdated Show resolved Hide resolved
examples/test/test_ai_society_example.py Outdated Show resolved Hide resolved
camel/generators.py Outdated Show resolved Hide resolved
camel/prompts/prompt_templates.py Outdated Show resolved Hide resolved
camel/societies/role_playing.py Outdated Show resolved Hide resolved
@Appointat Appointat linked an issue Aug 15, 2023 that may be closed by this pull request
2 tasks
@Appointat Appointat added the enhancement New feature or request label Aug 15, 2023
camel/societies/role_playing.py Outdated Show resolved Hide resolved
examples/test/test_ai_society_example.py Outdated Show resolved Hide resolved
Copy link
Member

@lightaime lightaime left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think all the with_role_description flags should be removed and just create new ASSISTANT_PROMPT and USER_PROMPT prompts with role_description in it.

camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/agents/role_assignment.py Outdated Show resolved Hide resolved
camel/prompts/ai_society.py Show resolved Hide resolved
Appointat and others added 18 commits August 18, 2023 11:21
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: zhiyu-01 <121875294+zhiyu-01@users.noreply.github.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: MorphlingEd <s1973609@ed.ac.uk>
Co-authored-by: Tianqi Xu <40522713+dandansamax@users.noreply.github.com>
Co-authored-by: Wenxuan Li <55635778+MorphlingEd@users.noreply.github.com>
Co-authored-by: zhiyu-01 <121875294+zhiyu-01@users.noreply.github.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: MorphlingEd <s1973609@ed.ac.uk>
Co-authored-by: Tianqi Xu <40522713+dandansamax@users.noreply.github.com>
Co-authored-by: Wenxuan Li <55635778+MorphlingEd@users.noreply.github.com>
Copy link
Member

@lightaime lightaime left a comment

Choose a reason for hiding this comment

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

Thanks, @Appointat. This is very cool. Left some comments. Let me know if there is any question!

camel/agents/role_assignment_agent.py Outdated Show resolved Hide resolved
camel/agents/role_assignment_agent.py Outdated Show resolved Hide resolved
camel/agents/role_assignment_agent.py Outdated Show resolved Hide resolved
camel/agents/role_assignment_agent.py Outdated Show resolved Hide resolved
camel/agents/role_assignment_agent.py Outdated Show resolved Hide resolved
Comment on lines 21 to 29
def test_role_generation_example():
with patch('time.sleep', return_value=None):
examples.role_description.role_generation.main(ModelType.GPT_3_5_TURBO)


def test_role_playing_with_role_description_example():
with patch('time.sleep', return_value=None):
examples.role_description.role_playing_with_role_description.main(
ModelType.GPT_3_5_TURBO)
Copy link
Member

Choose a reason for hiding this comment

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

Testing these two examples with ModelType.GPT_3_5_TURBO is too slow and expensive. Should we just patch the return and test them with ModelType.STUB?

camel/societies/role_playing.py Show resolved Hide resolved
Comment on lines 37 to 38
ai_assistant_role = role_names[AI_ASSISTANT_ROLE_INDEX]
ai_user_role = role_names[AI_USER_ROLE_INDEX]
Copy link
Member

Choose a reason for hiding this comment

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

How do we know which is the assistant role and which is the user role?

camel/agents/role_assignment_agent.py Show resolved Hide resolved
@ZhangT-tech ZhangT-tech self-assigned this Sep 4, 2023
@lightaime
Copy link
Member

Thanks @Appointat @ZhangT-tech for adding this awesome future!!

@lightaime lightaime enabled auto-merge (squash) September 8, 2023 23:58
@lightaime lightaime merged commit e780681 into master Sep 9, 2023
8 checks passed
@lightaime lightaime deleted the feature/role-generation branch September 9, 2023 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Feature Request] Automatic Role Generation with Descriptions for Two Roles
4 participants