Soumik555 commited on
Commit
ae28beb
·
1 Parent(s): 0dbfbd4

added together ai agent

Browse files
controller.py CHANGED
@@ -306,7 +306,7 @@ def langchain_csv_chat(csv_url: str, question: str, chart_required: bool):
306
  return_intermediate_steps=True
307
  )
308
 
309
- prompt = _prompt_generator(question, chart_required)
310
  result = agent.invoke({"input": prompt})
311
  return result.get("output")
312
 
@@ -537,7 +537,7 @@ def langchain_csv_chart(csv_url: str, question: str, chart_required: bool):
537
  return_intermediate_steps=True
538
  )
539
 
540
- result = agent.invoke({"input": _prompt_generator(question, True)})
541
  output = result.get("output", "")
542
 
543
  # Close figures to avoid interference
 
306
  return_intermediate_steps=True
307
  )
308
 
309
+ prompt = _prompt_generator(question, chart_required, csv_url)
310
  result = agent.invoke({"input": prompt})
311
  return result.get("output")
312
 
 
537
  return_intermediate_steps=True
538
  )
539
 
540
+ result = agent.invoke({"input": _prompt_generator(question, True, csv_url)})
541
  output = result.get("output", "")
542
 
543
  # Close figures to avoid interference
lc_groq_chart.py CHANGED
@@ -64,7 +64,7 @@ def langchain_csv_chart(csv_url: str, question: str, chart_required: bool):
64
  return_intermediate_steps=True
65
  )
66
 
67
- result = agent.invoke({"input": _prompt_generator(f"{question} and use this csv_url: {csv_url} to read the csv file", True)})
68
  output = result.get("output", "")
69
 
70
  # Verify chart file creation
 
64
  return_intermediate_steps=True
65
  )
66
 
67
+ result = agent.invoke({"input": _prompt_generator(question, True, csv_url)})
68
  output = result.get("output", "")
69
 
70
  # Verify chart file creation
lc_groq_chat.py CHANGED
@@ -63,7 +63,7 @@ def langchain_csv_chat(csv_url: str, question: str, chart_required: bool):
63
  return_intermediate_steps=True
64
  )
65
 
66
- prompt = _prompt_generator(question, chart_required)
67
  result = agent.invoke({"input": prompt})
68
  return result.get("output")
69
 
 
63
  return_intermediate_steps=True
64
  )
65
 
66
+ prompt = _prompt_generator(question, chart_required, csv_url)
67
  result = agent.invoke({"input": prompt})
68
  return result.get("output")
69
 
orchestrator_functions.py CHANGED
@@ -184,7 +184,7 @@ def langchain_csv_chat(csv_url: str, question: str, chart_required: bool):
184
  return_intermediate_steps=True
185
  )
186
 
187
- prompt = _prompt_generator(question, chart_required)
188
  result = agent.invoke({"input": prompt})
189
  return result.get("output")
190
 
@@ -324,7 +324,7 @@ def langchain_csv_chart(csv_url: str, question: str, chart_required: bool):
324
  return_intermediate_steps=True
325
  )
326
 
327
- result = agent.invoke({"input": _prompt_generator(f"{question} and use this csv_url: {csv_url} to read the csv file", True)})
328
  output = result.get("output", "")
329
 
330
  # Verify chart file creation
 
184
  return_intermediate_steps=True
185
  )
186
 
187
+ prompt = _prompt_generator(question, chart_required, csv_url)
188
  result = agent.invoke({"input": prompt})
189
  return result.get("output")
190
 
 
324
  return_intermediate_steps=True
325
  )
326
 
327
+ result = agent.invoke({"input": _prompt_generator(question, True, csv_url)})
328
  output = result.get("output", "")
329
 
330
  # Verify chart file creation
util_service.py CHANGED
@@ -22,7 +22,7 @@ def process_answer(answer):
22
  return False
23
 
24
 
25
- def _prompt_generator(question: str, chart_required: bool):
26
 
27
  chat_prompt = f"""You are a senior data analyst working with CSV data. Adhere strictly to the following guidelines:
28
 
@@ -30,6 +30,7 @@ def _prompt_generator(question: str, chart_required: bool):
30
  2. **Data Integrity:** Ensure proper handling of null values to maintain accuracy and reliability.
31
  3. **Communication:** Provide concise, professional, and well-structured responses.
32
  4. Avoid including any internal processing details or references to the methods used to generate your response (ex: based on the tool call, using the function -> These types of phrases.)
 
33
 
34
  **Query:** {question}
35
 
@@ -65,6 +66,7 @@ def _prompt_generator(question: str, chart_required: bool):
65
  - Use THE SAME unique_id throughout entire process
66
  - NEVER generate new UUIDs after initial creation
67
  - Return EXACT filepath string of the final saved chart
 
68
  """
69
 
70
 
 
22
  return False
23
 
24
 
25
+ def _prompt_generator(question: str, chart_required: bool, csv_url: str):
26
 
27
  chat_prompt = f"""You are a senior data analyst working with CSV data. Adhere strictly to the following guidelines:
28
 
 
30
  2. **Data Integrity:** Ensure proper handling of null values to maintain accuracy and reliability.
31
  3. **Communication:** Provide concise, professional, and well-structured responses.
32
  4. Avoid including any internal processing details or references to the methods used to generate your response (ex: based on the tool call, using the function -> These types of phrases.)
33
+ 5. Always use pd.read_csv({csv_url}) to read the CSV file.
34
 
35
  **Query:** {question}
36
 
 
66
  - Use THE SAME unique_id throughout entire process
67
  - NEVER generate new UUIDs after initial creation
68
  - Return EXACT filepath string of the final saved chart
69
+ - Always use pd.read_csv({csv_url}) to read the CSV file
70
  """
71
 
72