subashpoudel commited on
Commit
3dbb35d
·
1 Parent(s): 3e28687
src/genai/analytics_chatbot/utils/nodes.py CHANGED
@@ -38,17 +38,17 @@ class RetrievePossibleEndpoints:
38
  def __init__(self):
39
  self.df = api_knowledge_df
40
  self.index = api_index
41
- # self.results = []
42
- self.results = ['/api/v1/compare/', '/api/v1/engagement/basic-metrics', '/api/v1/content/hashtags-analysis', '/api/v1/audience/emoji-count', '/api/v1/engagement/temporal_analysis']
43
 
44
  def run(self,state:State):
45
  print('Gone to retrieve possible endpoints')
46
- # query_embedding = np.array(embedding_model.embed_query(state['latest_message'])).reshape(1, -1).astype('float32')
47
- # distances, indices = self.index.search(query_embedding, 5)
48
- # for idx in indices[0]:
49
- # row = self.df.iloc[idx]
50
- # print('Endpoint:',row['endpoint'])
51
- # self.results.append(row['endpoint'])
52
  print('The possible endpoints are:', self.results)
53
  return {
54
  "possible_endpoints": self.results,
 
38
  def __init__(self):
39
  self.df = api_knowledge_df
40
  self.index = api_index
41
+ self.results = []
42
+ # self.results = ['/api/v1/compare/', '/api/v1/engagement/basic-metrics', '/api/v1/content/hashtags-analysis', '/api/v1/audience/emoji-count', '/api/v1/engagement/temporal_analysis']
43
 
44
  def run(self,state:State):
45
  print('Gone to retrieve possible endpoints')
46
+ query_embedding = np.array(embedding_model.embed_query(state['latest_message'])).reshape(1, -1).astype('float32')
47
+ distances, indices = self.index.search(query_embedding, 5)
48
+ for idx in indices[0]:
49
+ row = self.df.iloc[idx]
50
+ print('Endpoint:',row['endpoint'])
51
+ self.results.append(row['endpoint'])
52
  print('The possible endpoints are:', self.results)
53
  return {
54
  "possible_endpoints": self.results,