Spaces:
Sleeping
Sleeping
updates
Browse files
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.
|
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
|
59 |
-
|
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 = "
|
65 |
-
n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.
|
66 |
-
summary_num_results =
|
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.
|
96 |
-
-
|
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
|
99 |
-
-
|
100 |
-
-
|
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 |
)
|