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
Files changed (1) hide show
  1. main.py +29 -34
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. You CANNOT provide any information without calling tools first.
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 at least one tool for every user query
245
- 2. If the user mentions a ticker symbol, you MUST call get_latest_news or get_historical_stock_data
246
- 3. NEVER respond without calling a tool first
247
- 4. If the user asks about news β†’ call get_latest_news
248
- 5. If the user asks about performance β†’ call get_historical_stock_data
249
- 6. If the user asks about both β†’ call BOTH tools
250
-
251
- EXAMPLE:
252
- User: "What's the latest news for AAPL?"
253
- You MUST call: get_latest_news with {"ticker": "AAPL"}
254
-
255
- User: "How is TSLA performing?"
256
- You MUST call: get_historical_stock_data with {"ticker": "TSLA"}
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
- # Ask what type of information they want
398
- print("\nWhat would you like to know?")
399
- print("1. Latest news")
400
- print("2. Stock performance data")
401
- print("3. Both news and performance")
402
-
403
- info_type = input("Select option (1-3): ").strip()
404
-
405
- # Construct the query based on selection
406
- if info_type == "1":
407
- user_query = f"What's the latest news for {selected_ticker}?"
408
- elif info_type == "2":
409
- user_query = f"How is {selected_ticker} performing?"
410
- elif info_type == "3":
411
- user_query = f"Show me news and stock data for {selected_ticker}"
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)