Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Competitive Intel Agent is a financial analyst solution that enables peer comparison with respect to their quarterly earnings P&L and stock prices.
Analysis of highly complex financial documents is effort and time intensive and error prone. With the help of AI Agentic workflow this complex task could now be automated and provide insights in comparatively much lesser time.
The solution has used sentence-transformers for embeddings and FAISS for vector storage. The workflow is managed using the LangChain framework directly, ensuring that the agents and tools interact in a structured manner. OLLAMA is correctly set up to host LLAMA 3.1 which is the LLM model being used. Streamlit is the front end of the solution.
Okay, let's break down this code snippet in a simple, tutorial-like way:
1**. Setting up the Brain (LLM)**
From langchain.llms import Ollama: This line brings in a special tool called "Ollama" from the langchain library. Ollama helps you connect to a powerful language model called LLAMA 3.1. Think of LLAMA 3.1 as the brain , capable of understanding and generating human-like text.
llm = Ollama(model="llama3.1"): Here, we are creating an instance of the Ollama tool and telling it to use the "llama3.1" model.
2. Giving the Robot Hands (Tools)
Tools = [...]: This is where we give different tools to work with. Each Tool has:
name: A simple name like "RAG Agent" or "Mathematical Calculation."
Function: The actual function or code that performs the task (e.g., retrieving information, doing calculations).
Description: A helpful description of what the tool does.
3. Teaching the Agent to Communicate (Prompt Template)
prompt_template = """...""": This is like a template or a script that we give to the agent. It tells the agent:
Its role: "You are a financial analyst."
Its task: "Your task is to analyze financial statements and provide insights."
Placeholders ({input}, {agent_scratchpad}): These are filled in with specific information during the analysis.
4. Understanding theAgent's Responses (Output Parser)
class CustomOutputParser(...): This part is like a translator. It helps you understand what agent is saying. The agent might say things like "I need to use the RAG Agent to find some data" or "Final Answer: The company's profit margin is 15%." The CustomOutputParser takes the agent's raw output and translates it into clear instructions or final answers.
5. Creating the Agent
Agent = LLMSingleActionAgent(...): This is where we finally assemble the agent! we give it:
llm_chain: The brain (LLAMA 3.1) and the communication script (prompt template).
output_parser: The translator to understand its responses.
stop=["\nObservation:"]: A way to tell the robot when to stop generating text.
allowed_tools: A list of tools the robot is allowed to use.
6. Activating the Robot (Agent Executor)
agent_executor = AgentExecutor.from_agent_and_tools(...): This is like turning the agent on! We give it the assembled agent and the tools, and now it's ready to receive instructions and perform tasks.
In simpler terms: We have built a competitive intel agent with a powerful brain (LLAMA 3.1). We've given it tools to find information, do calculations, and draw conclusions. We have trained the agent to analyze financial statements!
(https://github.com/user-attachments/files/17792704/Competitive.Intel.Agent_V1.0.pdf)
Competitive Intel Agent_V1.0.pdf