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

Competitive Intel Agent #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

koyeliaghosh
Copy link

@koyeliaghosh koyeliaghosh commented Nov 17, 2024

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

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.

1 participant