ofermend commited on
Commit
72e1546
1 Parent(s): ece9872
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -44,7 +44,7 @@ def create_tools(cfg):
44
  return years
45
 
46
  class QueryFinancialReportsArgs(BaseModel):
47
- query: str = Field(..., description="The user query. Must be a question about the company's financials, and should not include the company name, ticker or year.")
48
  year: int = Field(..., description=f"The year. an integer between {min(years)} and {max(years)}.")
49
  ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
50
 
@@ -55,15 +55,14 @@ def create_tools(cfg):
55
  tool_name = "query_financial_reports",
56
  tool_description = """
57
  Given a company name and year,
58
- returns a response (str) to a user query about the company's financials for that year.
59
- When using this tool, make sure to provide the a valid company ticker and a year.
60
- Use this tool to get financial information one metric at a time.
61
  """,
62
  tool_args_schema = QueryFinancialReportsArgs,
63
  tool_filter_template = "doc.year = {year} and doc.ticker = '{ticker}'",
64
- reranker = "slingshot", rerank_k = 100,
65
- n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.0,
66
- summary_num_results = 15,
67
  vectara_summarizer = 'vectara-summary-ext-24-05-med-omni',
68
  )
69
 
@@ -92,19 +91,20 @@ def launch_bot(agent_type: AgentType):
92
  st.session_state.thinking_placeholder.text(output)
93
 
94
  financial_bot_instructions = """
95
- - You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
96
- - You can answer questions, provide insights, or summarize any information from financial reports.
97
  - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
98
- - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
99
- - In many cases you may need to query tools on each sub-metric separately before computing the final metric.
100
- - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the the following year's report.
101
  - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
 
 
102
  """
103
-
104
  st.session_state.agent = Agent(
105
  agent_type = agent_type,
106
  tools = create_tools(cfg),
107
- topic = "10-K financial reports",
108
  custom_instructions = financial_bot_instructions,
109
  update_func = update_func
110
  )
 
44
  return years
45
 
46
  class QueryFinancialReportsArgs(BaseModel):
47
+ query: str = Field(..., description="The user query.")
48
  year: int = Field(..., description=f"The year. an integer between {min(years)} and {max(years)}.")
49
  ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
50
 
 
55
  tool_name = "query_financial_reports",
56
  tool_description = """
57
  Given a company name and year,
58
+ returns a response (str) to a user query about the company's financial reports for that year.
59
+ make sure to provide the a valid company ticker and year.
 
60
  """,
61
  tool_args_schema = QueryFinancialReportsArgs,
62
  tool_filter_template = "doc.year = {year} and doc.ticker = '{ticker}'",
63
+ reranker = "multilingual_reranker_v1", rerank_k = 100,
64
+ n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.01,
65
+ summary_num_results = 10,
66
  vectara_summarizer = 'vectara-summary-ext-24-05-med-omni',
67
  )
68
 
 
91
  st.session_state.thinking_placeholder.text(output)
92
 
93
  financial_bot_instructions = """
94
+ - You are a helpful financial assistant in conversation with a user.
95
+ - Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate responses.
96
  - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
97
+ - When using a query tool for a metric, make sure to provide the correct ticker and year and concise definition of the metric to avoid ambiguity.
98
+ - Use tools when available instead of depending on your own knowledge, and consider the field descriptions carefully.
99
+ - If you calculate a metric, make sure you have all the necessary information to complete the calculation. Don't guess.
100
  - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
101
+ - Be very careful not to report results you are not confident about.
102
+ - Report results in the most relevant multiple. For example, reveuues in millions, not thousands.
103
  """
 
104
  st.session_state.agent = Agent(
105
  agent_type = agent_type,
106
  tools = create_tools(cfg),
107
+ topic = "10-K annual financial reports",
108
  custom_instructions = financial_bot_instructions,
109
  update_func = update_func
110
  )