Sush commited on
Commit
c5af905
·
1 Parent(s): f890139

Add INR formatting

Browse files
Files changed (2) hide show
  1. agents/rag_agent.py +15 -1
  2. app.py +7 -1
agents/rag_agent.py CHANGED
@@ -92,7 +92,21 @@ Answer:"""
92
  )
93
 
94
  def format_docs(docs):
95
- return "\n\n".join(doc.page_content for doc in docs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  # LCEL chain
98
  rag_chain = (
 
92
  )
93
 
94
  def format_docs(docs):
95
+ formatted = []
96
+ sources = set()
97
+
98
+ for doc in docs:
99
+ source = doc.metadata.get("source", "Unknown")
100
+ filename = os.path.basename(source)
101
+
102
+ sources.add(filename)
103
+ formatted.append(doc.page_content)
104
+
105
+ context = "\n\n".join(formatted)
106
+
107
+ source_text = "\n\nSources:\n" + "\n".join(f"- {s}" for s in sources)
108
+
109
+ return context + source_text
110
 
111
  # LCEL chain
112
  rag_chain = (
app.py CHANGED
@@ -1,12 +1,18 @@
1
  import sys
2
  import os
3
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 
4
 
5
  import streamlit as st
6
  from agents.rag_agent import load_rag_agent
7
  from agents.sql_agent import load_sql_agent
8
  from agents.orchestrator import build_orchestrator
9
 
 
 
 
 
 
10
  # ── PAGE CONFIG ──
11
  st.set_page_config(
12
  page_title="HDFC Banking Intelligence Assistant",
@@ -72,7 +78,7 @@ if query := st.chat_input("Ask your banking question here..."):
72
  "response": ""
73
  })
74
 
75
- response = result["response"]
76
  agent_used = result["agent_used"].upper()
77
 
78
  # Show which agent handled it
 
1
  import sys
2
  import os
3
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
4
+ import streamlit as st
5
 
6
  import streamlit as st
7
  from agents.rag_agent import load_rag_agent
8
  from agents.sql_agent import load_sql_agent
9
  from agents.orchestrator import build_orchestrator
10
 
11
+ import re
12
+
13
+ def format_currency(text):
14
+ return re.sub(r"\$(\d+(?:,\d+)*(?:\.\d+)?)", r"₹\1", text)
15
+
16
  # ── PAGE CONFIG ──
17
  st.set_page_config(
18
  page_title="HDFC Banking Intelligence Assistant",
 
78
  "response": ""
79
  })
80
 
81
+ response = format_currency(result["response"])
82
  agent_used = result["agent_used"].upper()
83
 
84
  # Show which agent handled it