File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1696,13 +1696,35 @@ <h4>⚠️ Input Tidak Valid</h4>
16961696
16971697 try {
16981698 // ✅ GUNA API_KEY YANG DAH DI DECRYPT
1699- const response = await fetch ( `${ IPFS_CONFIG . aiEndpoint } ?key=${ API_KEY } ` , {
1700- method : 'POST' ,
1701- headers : {
1702- 'Content-Type' : 'application/json'
1703- } ,
1704- body : JSON . stringify ( payload )
1705- } ) ;
1699+ // Dalam function generateAIAnswer(), gantikan bahagian ni:
1700+
1701+ const payload = {
1702+ contents : [ {
1703+ parts : [ { text : prompt } ]
1704+ } ]
1705+ } ;
1706+
1707+ try {
1708+ // ✅ GUNA PROXY (BUKAN PANGGIL GOOGLE TERUS)
1709+ const response = await fetch ( '/api/proxy' , {
1710+ method : 'POST' ,
1711+ headers : {
1712+ 'Content-Type' : 'application/json'
1713+ } ,
1714+ body : JSON . stringify ( {
1715+ prompt : query // Hantar prompt je
1716+ } )
1717+ } ) ;
1718+
1719+ if ( ! response . ok ) {
1720+ const err = await response . json ( ) ;
1721+ throw new Error ( err . error ?. message || "AI API Error" ) ;
1722+ }
1723+
1724+ const data = await response . json ( ) ;
1725+ const aiText = data . candidates ?. [ 0 ] ?. content ?. parts ?. [ 0 ] ?. text ;
1726+
1727+
17061728
17071729 if ( ! response . ok ) {
17081730 const err = await response . json ( ) ;
You can’t perform that action at this time.
0 commit comments