ofermend commited on
Commit
3201760
·
1 Parent(s): 75c6666

updated finance tools

Browse files
Files changed (1) hide show
  1. agent.py +9 -5
agent.py CHANGED
@@ -29,7 +29,7 @@ tickers = {
29
  "BK": "Bank of New York Mellon",
30
  "C": "Citigroup",
31
  }
32
- years = [2020, 2021, 2022, 2023, 2024]
33
  initial_prompt = "How can I help you today?"
34
 
35
  def create_assistant_tools(cfg):
@@ -50,7 +50,7 @@ def create_assistant_tools(cfg):
50
  return years
51
 
52
  # Tool to get the income statement for a given company and year using the FMP API
53
- def get_income_statement(
54
  ticker: str = Field(description="the ticker symbol of the company."),
55
  year: int = Field(description="the year for which to get the income statement."),
56
  ) -> str:
@@ -77,6 +77,8 @@ def create_assistant_tools(cfg):
77
 
78
  return f"FMP API returned error {response.status_code}. This tool does not work."
79
 
 
 
80
  class QueryTranscriptsArgs(BaseModel):
81
  query: str = Field(..., description="The user query.")
82
  year: int = Field(..., description=f"The year this query relates to. An integer between {min(years)} and {max(years)}.")
@@ -106,7 +108,7 @@ def create_assistant_tools(cfg):
106
  [
107
  get_company_info,
108
  get_valid_years,
109
- get_income_statement,
110
  ]
111
  ] +
112
  tools_factory.financial_tools() +
@@ -118,14 +120,16 @@ def initialize_agent(_cfg, agent_progress_callback=None):
118
  - You are a helpful financial assistant, with expertise in financial reporting, in conversation with a user.
119
  - Use the ask_transcripts tool to answer most questions about the company's financial performance, risks, opportunities, strategy, competitors, and more.
120
  - responses from ask_transcripts are summarized. You don't need to further summarize them.
121
- - Use the get_income_statement tool only to receive financial data like revenue, net income, and other financial metrics for a specific company and year.
122
  - Respond in a compact format by using appropriate units of measure (e.g., K for thousands, M for millions, B for billions).
123
  Do not report the same number twice (e.g. $100K and 100,000 USD).
124
- - Always check the get_company_info and get_valid_years tools to validate company and year are valid.
 
 
125
  - Do not include URLs unless they are provided in the output of a tool you use.
126
  - When querying a tool for a numeric value or KPI, use a concise and non-ambiguous description of what you are looking for.
127
  - If you calculate a metric, make sure you have all the necessary information to complete the calculation. Don't guess.
128
  """
 
129
 
130
  agent = Agent(
131
  tools=create_assistant_tools(_cfg),
 
29
  "BK": "Bank of New York Mellon",
30
  "C": "Citigroup",
31
  }
32
+ years = range(2015, 2025)
33
  initial_prompt = "How can I help you today?"
34
 
35
  def create_assistant_tools(cfg):
 
50
  return years
51
 
52
  # Tool to get the income statement for a given company and year using the FMP API
53
+ def fmp_income_statement(
54
  ticker: str = Field(description="the ticker symbol of the company."),
55
  year: int = Field(description="the year for which to get the income statement."),
56
  ) -> str:
 
77
 
78
  return f"FMP API returned error {response.status_code}. This tool does not work."
79
 
80
+
81
+
82
  class QueryTranscriptsArgs(BaseModel):
83
  query: str = Field(..., description="The user query.")
84
  year: int = Field(..., description=f"The year this query relates to. An integer between {min(years)} and {max(years)}.")
 
108
  [
109
  get_company_info,
110
  get_valid_years,
111
+ fmp_income_statement,
112
  ]
113
  ] +
114
  tools_factory.financial_tools() +
 
120
  - You are a helpful financial assistant, with expertise in financial reporting, in conversation with a user.
121
  - Use the ask_transcripts tool to answer most questions about the company's financial performance, risks, opportunities, strategy, competitors, and more.
122
  - responses from ask_transcripts are summarized. You don't need to further summarize them.
 
123
  - Respond in a compact format by using appropriate units of measure (e.g., K for thousands, M for millions, B for billions).
124
  Do not report the same number twice (e.g. $100K and 100,000 USD).
125
+ - Always use the 'income_statement' tool to obtain accurate financial data like revenues, expenses, net income, and other financial metrics for a specific company for the last 5 years.
126
+ - Use the 'fmp_income_statement' tool (with the company ticker and year) to obtain financial data for any year before 2020.
127
+ - Always check the 'get_company_info' and 'get_valid_years' tools to validate company and year are valid.
128
  - Do not include URLs unless they are provided in the output of a tool you use.
129
  - When querying a tool for a numeric value or KPI, use a concise and non-ambiguous description of what you are looking for.
130
  - If you calculate a metric, make sure you have all the necessary information to complete the calculation. Don't guess.
131
  """
132
+ # - Use the get_income_statement tool only to receive financial data like revenue, net income, and other financial metrics for a specific company and year.
133
 
134
  agent = Agent(
135
  tools=create_assistant_tools(_cfg),