Spaces:
Running
Running
Faham
commited on
Commit
Β·
e501d8f
1
Parent(s):
6cd9238
UPDATE: responses are now more cleaner and according to the query and data available
Browse files
main.py
CHANGED
|
@@ -234,28 +234,26 @@ async def execute_tool_call(tool_call):
|
|
| 234 |
|
| 235 |
# The master prompt that defines the agent's behavior
|
| 236 |
system_prompt = """
|
| 237 |
-
You are a financial assistant. You MUST use tools to get data
|
| 238 |
|
| 239 |
AVAILABLE TOOLS:
|
| 240 |
- get_latest_news: Get recent news for a ticker
|
| 241 |
- get_historical_stock_data: Get stock performance data for a ticker
|
| 242 |
|
| 243 |
CRITICAL INSTRUCTIONS:
|
| 244 |
-
1. You MUST call
|
| 245 |
-
2.
|
| 246 |
-
3.
|
| 247 |
-
4.
|
| 248 |
-
5.
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
You
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
You
|
| 257 |
-
|
| 258 |
-
You are FORBIDDEN from responding without calling a tool. Always call a tool first, then provide your response based on the tool results.
|
| 259 |
"""
|
| 260 |
|
| 261 |
|
|
@@ -394,24 +392,21 @@ async def main():
|
|
| 394 |
selected_ticker = available_tickers[selection]
|
| 395 |
print(f"\nπ Selected: {selected_ticker}")
|
| 396 |
|
| 397 |
-
#
|
| 398 |
-
print("\
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
else:
|
| 413 |
-
print("β Invalid option. Using default query.")
|
| 414 |
-
user_query = f"How is {selected_ticker} performing?"
|
| 415 |
|
| 416 |
# Run the agent with the user's query
|
| 417 |
await run_agent(user_query)
|
|
|
|
| 234 |
|
| 235 |
# The master prompt that defines the agent's behavior
|
| 236 |
system_prompt = """
|
| 237 |
+
You are a financial assistant that provides comprehensive analysis based on real-time data. You MUST use tools to get data and then curate the information to answer the user's specific question.
|
| 238 |
|
| 239 |
AVAILABLE TOOLS:
|
| 240 |
- get_latest_news: Get recent news for a ticker
|
| 241 |
- get_historical_stock_data: Get stock performance data for a ticker
|
| 242 |
|
| 243 |
CRITICAL INSTRUCTIONS:
|
| 244 |
+
1. You MUST call BOTH tools (get_latest_news AND get_historical_stock_data) for every query
|
| 245 |
+
2. After getting both news and stock data, analyze and synthesize the information
|
| 246 |
+
3. Answer the user's specific question based on the data you gathered
|
| 247 |
+
4. Provide insights, trends, and recommendations based on the combined data
|
| 248 |
+
5. Format your response clearly with sections for news, performance, and analysis
|
| 249 |
+
|
| 250 |
+
EXAMPLE WORKFLOW:
|
| 251 |
+
1. User asks: "Should I invest in AAPL?"
|
| 252 |
+
2. You call: get_latest_news with {"ticker": "AAPL"}
|
| 253 |
+
3. You call: get_historical_stock_data with {"ticker": "AAPL"}
|
| 254 |
+
4. You analyze both datasets and provide investment advice based on news sentiment and stock performance
|
| 255 |
+
|
| 256 |
+
You are FORBIDDEN from responding without calling both tools. Always call both tools first, then provide a curated analysis based on the user's question.
|
|
|
|
|
|
|
| 257 |
"""
|
| 258 |
|
| 259 |
|
|
|
|
| 392 |
selected_ticker = available_tickers[selection]
|
| 393 |
print(f"\nπ Selected: {selected_ticker}")
|
| 394 |
|
| 395 |
+
# Always fetch both news and stock data by default
|
| 396 |
+
print(f"\nπ Fetching comprehensive data for {selected_ticker}...")
|
| 397 |
+
|
| 398 |
+
# Get user's specific question
|
| 399 |
+
user_question = input(
|
| 400 |
+
f"\n㪠What would you like to know about {selected_ticker}? (e.g., 'How is it performing?', 'What's the latest news?', 'Should I invest?'): "
|
| 401 |
+
).strip()
|
| 402 |
+
|
| 403 |
+
if not user_question:
|
| 404 |
+
user_question = (
|
| 405 |
+
f"How is {selected_ticker} performing and what's the latest news?"
|
| 406 |
+
)
|
| 407 |
+
|
| 408 |
+
# Construct the query to always fetch both data types
|
| 409 |
+
user_query = f"Based on the latest news and stock performance data for {selected_ticker}, {user_question}"
|
|
|
|
|
|
|
|
|
|
| 410 |
|
| 411 |
# Run the agent with the user's query
|
| 412 |
await run_agent(user_query)
|