ashishbangwal commited on
Commit
72243d9
·
1 Parent(s): 74ccf83

new tool added

Browse files
data_ingetion/data_api.py CHANGED
@@ -1,6 +1,6 @@
1
  from fastapi import APIRouter
2
  from pydantic import BaseModel
3
- from .market_data import price_change, earning_summary, portfolio_data
4
  from .vectroDB import get_relevant_chunks
5
 
6
  app = APIRouter()
@@ -43,3 +43,8 @@ def get_portfolio_data(req: PortfolioReq):
43
  @app.post("/get_knowledge")
44
  def get_knowledge(req: KnowledgeReq):
45
  return {"response": get_relevant_chunks(req.query)}
 
 
 
 
 
 
1
  from fastapi import APIRouter
2
  from pydantic import BaseModel
3
+ from .market_data import price_change, earning_summary, portfolio_data, get_update
4
  from .vectroDB import get_relevant_chunks
5
 
6
  app = APIRouter()
 
43
  @app.post("/get_knowledge")
44
  def get_knowledge(req: KnowledgeReq):
45
  return {"response": get_relevant_chunks(req.query)}
46
+
47
+
48
+ @app.post("/get_update")
49
+ def get_ticker_update(req: EarningReq):
50
+ return {"response": get_update(req.symbol)}
data_ingetion/market_data.py CHANGED
@@ -5,6 +5,7 @@ import os
5
 
6
 
7
  def portfolio_data(region: str = "IND"):
 
8
  if region == "IND":
9
  portfolio = "/data_ingetion/portfolios/IND.csv"
10
  else:
@@ -82,3 +83,19 @@ def earning_summary(symbol):
82
  response = f"Earning metrics for {symbol} are following in {currency} currency in {units}: \n {selected_metric}"
83
 
84
  return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
 
7
  def portfolio_data(region: str = "IND"):
8
+ region = "IND"
9
  if region == "IND":
10
  portfolio = "/data_ingetion/portfolios/IND.csv"
11
  else:
 
83
  response = f"Earning metrics for {symbol} are following in {currency} currency in {units}: \n {selected_metric}"
84
 
85
  return response
86
+
87
+
88
+ def get_update(symbol):
89
+ stock = yf.Ticker(ticker=symbol)
90
+ data = stock.news
91
+ news = ""
92
+
93
+ for info in data[:5]:
94
+ news += info["content"]["title"] + "\n"
95
+ news += info["content"]["summary"] + "\n\n"
96
+
97
+ pc = price_change(symbol, 7)
98
+
99
+ response = f"Price change for {symbol} in past 7 days is {pc} \n\n NEWS :\n\n{news}"
100
+
101
+ return response
orchestrator/orchestrator.py CHANGED
@@ -47,6 +47,11 @@ def get_orchertration_resposne(query, history):
47
  url="http://127.0.0.1:7860/data/get_knowledge", json=data["parameters"]
48
  ).json()
49
 
 
 
 
 
 
50
  elif data["tool"] == None:
51
  return data["parameters"]
52
 
 
47
  url="http://127.0.0.1:7860/data/get_knowledge", json=data["parameters"]
48
  ).json()
49
 
50
+ elif data["tool"] == "get_update":
51
+ result = requests.post(
52
+ url="http://127.0.0.1:7860/data/get_update", json=data["parameters"]
53
+ ).json()
54
+
55
  elif data["tool"] == None:
56
  return data["parameters"]
57
 
orchestrator/prompts.py CHANGED
@@ -19,6 +19,8 @@ Tools available:
19
  get_knowledge() -> use this tool to get prior knowledge as context about the firm, its a RAG based tool ie. you will give the augmented user query for better retrival results.
20
  parameters -> query:str User query augmented/expanded by you for better retrival results
21
 
 
 
22
 
23
 
24
  You have to respond in structured json format, mentioning tool name and prameter json.
@@ -47,9 +49,19 @@ response :
47
  }
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  Dont add any comments around json, you should only respond in valid json format only.
52
  """
53
  FINAL_SYS_PROMPT = """
54
- You task to to generate final response of a long workflow/reseach. You will be provided with Query that is the original query and some context that is derived from different tools your task is to create a condensed output to effectively answer the user query. Try to be consise and to the point. Also not necessarily but do add disclamers if there is any uncertanity. Stay respectful and official tone. Talk like a financial expert.
55
  """
 
19
  get_knowledge() -> use this tool to get prior knowledge as context about the firm, its a RAG based tool ie. you will give the augmented user query for better retrival results.
20
  parameters -> query:str User query augmented/expanded by you for better retrival results
21
 
22
+ get_update() -> use this tool to get latest news and price movement in the stock/index. This information can be helpful in providing sentiments around the stock or index. Can also be used to tell general market trends by getting info on indexes like NIFTY50 (yfinance - ^NSEI).
23
+ parameters -> symbol:str the symbol of the stock/index yfinance style.
24
 
25
 
26
  You have to respond in structured json format, mentioning tool name and prameter json.
 
49
  }
50
  }
51
 
52
+ Query : How does general market looks like ?
53
+
54
+ response :
55
+ {
56
+ "tool":"get_update",
57
+ "parameters" : {
58
+ "response" : "^NSEI"
59
+ }
60
+ }
61
+
62
 
63
  Dont add any comments around json, you should only respond in valid json format only.
64
  """
65
  FINAL_SYS_PROMPT = """
66
+ You task to to generate final response of a long workflow/reseach. You will be provided with Query that is the original query and some context that is derived from different tools your task is to create a condensed output to effectively answer the user query. Try to be consise and to the point. Also not necessarily but every now and then add disclamers if there is any uncertanity. Stay respectful and official tone. Talk like a financial expert.
67
  """