@@ -20,12 +20,14 @@ interface ChatMessage {
2020
2121const SAMPLE_QUESTIONS = [
2222 "Compare the average annual rainfall in Maharashtra and Punjab" ,
23+ "What are the current crop prices in Maharashtra?" ,
24+ "Show me latest market rates for Punjab" ,
2325 "Which state has the highest rice production?" ,
24- "Show me the correlation between rainfall and crop production" ,
25- "What is the average wheat production in Punjab?" ,
2626 "Analyze the production trend of cotton from 2010 to 2014"
2727] ;
2828
29+ const LIVE_KEYWORDS = [ 'current' , 'latest' , 'recent' , 'live' , 'today' , 'now' , 'market' , 'price' ] ;
30+
2931export default function Home ( ) {
3032 const [ messages , setMessages ] = useState < ChatMessage [ ] > ( [ ] ) ;
3133 const [ input , setInput ] = useState ( '' ) ;
@@ -141,6 +143,9 @@ export default function Home() {
141143 < span className = "ml-3 text-sm font-normal text-gray-600" >
142144 Intelligent Q& A for Indian Agriculture
143145 </ span >
146+ < span className = "ml-3 px-2 py-1 text-xs bg-green-100 text-green-700 rounded-full" >
147+ LIVE API
148+ </ span >
144149 </ h1 >
145150 </ div >
146151 </ header >
@@ -150,17 +155,41 @@ export default function Home() {
150155 { /* Sample Questions */ }
151156 { messages . length === 0 && (
152157 < div className = "mb-8" >
158+ < div className = "mb-6 p-4 bg-gradient-to-r from-green-50 to-blue-50 rounded-lg border border-green-200" >
159+ < h2 className = "text-lg font-semibold text-gray-800 mb-2 flex items-center" >
160+ ⚡ Live Data Integration Active
161+ </ h2 >
162+ < p className = "text-sm text-gray-600" >
163+ System automatically fetches < strong > real-time data</ strong > from data.gov.in API for current queries,
164+ and uses historical data for trend analysis.
165+ </ p >
166+ </ div >
167+
153168 < h2 className = "text-lg font-semibold text-gray-800 mb-4" > Try these sample questions:</ h2 >
154169 < div className = "grid gap-3 md:grid-cols-2" >
155- { SAMPLE_QUESTIONS . map ( ( question , index ) => (
156- < button
157- key = { index }
158- onClick = { ( ) => handleSampleQuestion ( question ) }
159- className = "p-3 text-left bg-white rounded-lg border hover:border-blue-300 hover:bg-blue-50 transition-colors"
160- >
161- < span className = "text-sm text-gray-700" > { question } </ span >
162- </ button >
163- ) ) }
170+ { SAMPLE_QUESTIONS . map ( ( question , index ) => {
171+ const isLive = LIVE_KEYWORDS . some ( keyword => question . toLowerCase ( ) . includes ( keyword ) ) ;
172+ return (
173+ < button
174+ key = { index }
175+ onClick = { ( ) => handleSampleQuestion ( question ) }
176+ className = { `p-3 text-left rounded-lg border transition-colors ${
177+ isLive
178+ ? 'bg-green-50 border-green-200 hover:border-green-300 hover:bg-green-100'
179+ : 'bg-white hover:border-blue-300 hover:bg-blue-50'
180+ } `}
181+ >
182+ < div className = "flex items-start justify-between" >
183+ < span className = "text-sm text-gray-700" > { question } </ span >
184+ { isLive && (
185+ < span className = "ml-2 px-2 py-1 text-xs bg-green-100 text-green-700 rounded-full" >
186+ LIVE
187+ </ span >
188+ ) }
189+ </ div >
190+ </ button >
191+ ) ;
192+ } ) }
164193 </ div >
165194 </ div >
166195 ) }
@@ -181,6 +210,21 @@ export default function Home() {
181210 >
182211 < div className = "whitespace-pre-wrap" > { message . content } </ div >
183212
213+ { /* Data Source Indicator */ }
214+ { message . response && (
215+ < div className = "mt-2 flex items-center text-xs text-gray-500" >
216+ { message . response . processing_info . query_type === 'current' ? (
217+ < span className = "flex items-center px-2 py-1 bg-green-100 text-green-700 rounded-full" >
218+ ⚡ Live API Data
219+ </ span >
220+ ) : (
221+ < span className = "flex items-center px-2 py-1 bg-blue-100 text-blue-700 rounded-full" >
222+ 📈 Historical Data
223+ </ span >
224+ ) }
225+ </ div >
226+ ) }
227+
184228 { /* Structured Results */ }
185229 { message . response ?. structured_results && message . response . structured_results . length > 0 && (
186230 < div className = "mt-4 p-3 bg-gray-50 rounded border" >
0 commit comments