you may found some hard-code API_KEY in codes but don't worry the api is fully managed by myself and have a restriction.
work.pdf contains brief intro of out works'architecture and the results of the experiments.
This script simulates an AI-driven multi-agent dialogue system using multiple custom ConversableAgents and third-party libraries (e.g., OpenAI's GPT model) to collaboratively process user input for analysis and debate on topics related to the cryptocurrency market.
-
Dependency Importing
- Use a variety of external dependency libraries (e.g.
autogen-agentchat
,autogen-ext[openai,web-surfer]
,playwright
, etc.). - Load the
.env
file to set the API key and model URL configuration.
- Use a variety of external dependency libraries (e.g.
-
**ConversableAgent Definitions
- Defines multiple ConversableAgents with a clear division of responsibilities (news selection, debate support, summary logging, etc.):
- newsSelector: Filters and selects news related to the cryptocurrency market for the last seven days, blocking advertisements and irrelevant information.
- debateAdviser: analyses user comments and stores them sorted by pro and con.
- assistantRecorder: Records and summarizes the main points of a two-agent dialogue.
- debateParticipantA/B: Provide clear, relevant arguments as the pro and con sides of the debate.
- judge: Judge the strengths and weaknesses of both sides of the debate and choose a winner.
- host: moderates the flow of the dialogue, forcing the discussion to focus on the given topic. 3.
- Defines multiple ConversableAgents with a clear division of responsibilities (news selection, debate support, summary logging, etc.):
-
Dialogue Functions: Implement the `host.initiate
- implements the
host.initiate_chats
method, which assigns tasks to agents to simulate debates and analysis around cryptocurrency topics. - Each dialogue task has a custom input message, maximum number of rounds, summary strategy, etc.
- implements the
-
Data processing
- Read the
results.json
file, parse and construct user social media comments from the cryptocurrency market as input context. - Inject the parsed content into the user's initial message to provide dialogue context.
- Read the
-
Asynchronous main functions
- Run the above multi-agent dialogue logic asynchronously using asyncio.
- Generate dialogue result output at the end of the logic.
- Multi-Agent Collaboration: Define multiple ConversableAgents, each with its own role, to form a complex multi-agent dialogue and collaboration process.
- API Integration: Provide language generation and information retrieval capabilities for agents by configuring OpenAI GPT-4 models and tools from Google Search.
- Dynamic Context Management: Loads dynamic contexts for analysis by reading external JSON files and environment variables
The file main.py
implements a multi-intelligence based dialogue and analysis script focused on the cryptocurrency domain. It simulates an efficient information extraction, debate and summary process in the domain through a reasonable division of labour and context injection.
main.py
implements a multi-intelligence dialogue system that collaboratively generates summaries and decisions through analysis, filtering, and debate around topics related to the cryptocurrency market.
Module/Function Points | Description |
---|---|
Dependency Import | Introduces external libraries (e.g. autogen-ext and OpenAI API) and tools (e.g. dotenv and playwright ) for functionality extensions. |
ConversableAgent Definition | Define multiple agents (e.g., news filtering, comment analysis, debate participation, etc.) to implement different business logic responsibilities. |
Conversation Functionality | Use host to moderate agent conversations, simulating the process of debating and analyzing cryptocurrency market topics. |
Data Processing | |
Output Generation | Aggregate the results of the dialogue to generate a final summary and key points of the market-related debate. |
Asynchronous main function | Uses asyncio to drive the entire dialogue logic asynchronously, efficiently scheduling agent tasks for collaborative processing. |
Recommendation: Add exception handling and logging to each module to improve robustness.
Translated with DeepL.com (free version)
where:
- Term Frequency (TF): The frequency of word $( w_{i} ) $in the document:
- Inverse Document Frequency (IDF): A measure of how unique the word is across the entire corpus:
- Higher TF-IDF scores indicate that a word is important in the document (tweet) but not common across all documents.
- Words that appear frequently in one document but rarely in others will have higher importance scores.
Each engagement metric is normalized using Min-Max Scaling with 95th Percentile Clipping:
-
Clipping ensures outliers don’t dominate the scores.
$( 1e^{-8} )$ prevents division by zero.
- Each metric is scaled between 0 and 1.
- Values are adjusted to reduce the impact of outliers.
- Higher values indicate greater engagement relative to the dataset.
The Engagement Score is calculated as the sum of various engagement metrics:
( E ) = Engagement Score (total interactions on a tweet).
- Higher engagement scores indicate higher user interaction with the tweet.
- The score considers all forms of engagement, not just likes or retweets.
- Tweets with high engagement scores are more likely to be influential or viral.
The raw importance score is calculated as the product of the TF-IDF Score and the Engagement Score:
where:
- The TF-IDF Score captures textual importance based on how unique and relevant the words are.
- The Engagement Score captures user interaction with the tweet.
- Multiplication ensures that only highly engaged tweets with important textual content receive higher importance scores.
- This raw score will later be normalized to a 0-100 scale for better interpretability.