mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-07 13:00:59 +08:00
fix: NOFXi Agent real AI integration + quality improvements
Critical fixes: 1. Agent now uses NOFX's MCP client for AI calls (real models, not placeholder) - Gets AI client from first configured trader's MCP config - Added AutoTrader.GetMCPClient() export 2. /analyze uses REAL market data (market.Get → EMA/MACD/RSI/BB/OI/funding) then sends to AI — no more hallucinated prices 3. AI chat enriches prompts with live market data when user mentions a coin 4. Fallback: if AI unavailable, shows raw formatted market data (still useful) Router improvements: - Better natural language detection for Chinese - '该不该买' '走势' '趋势' '行情' → analyze intent - '多少钱' '赚了' '亏了' → query intent - Fewer messages falling through to generic chat Web UI: - Endpoints updated to /api/agent/* namespace - nofxi.html served at agent root (localhost:8900) Result: AI analysis now shows real BTC price, real RSI, real EMA — not fiction.
This commit is contained in:
@@ -291,7 +291,7 @@ checkSt(); setInterval(checkSt,30000);
|
||||
// === Ticker Info Bar ===
|
||||
async function loadInfoBar(){
|
||||
try{
|
||||
const r=await fetch(API+'/api/ticker?symbol=BTCUSDT');
|
||||
const r=await fetch(API+'/api/agent/ticker?symbol=BTCUSDT');
|
||||
const d=await r.json();
|
||||
if(!d.lastPrice) return;
|
||||
const bar=document.getElementById('infoBar');
|
||||
@@ -337,7 +337,7 @@ async function send(text){
|
||||
addM('user',text);
|
||||
typEl.classList.add('on');sBtnEl.disabled=true;inpEl.focus();
|
||||
try{
|
||||
const r=await fetch(API+'/api/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:text,user_id:1,lang:lang})});
|
||||
const r=await fetch(API+'/api/agent/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:text,user_id:1,lang:lang})});
|
||||
const d=await r.json();
|
||||
addM('bot',d.response||d.error||'No response');
|
||||
}catch(e){addM('bot','⚠️ Error: '+e.message)}
|
||||
@@ -380,7 +380,7 @@ function setTF(tf){
|
||||
async function loadChart(){
|
||||
const sym=document.getElementById('symSel').value;
|
||||
try{
|
||||
const[kr,tr]=await Promise.all([fetch(`${API}/api/klines?symbol=${sym}&interval=${curTF}&limit=300`),fetch(`${API}/api/ticker?symbol=${sym}`)]);
|
||||
const[kr,tr]=await Promise.all([fetch(`${API}/api/agent/klines?symbol=${sym}&interval=${curTF}&limit=300`),fetch(`${API}/api/agent/ticker?symbol=${sym}`)]);
|
||||
const klines=await kr.json(), ticker=await tr.json();
|
||||
if(klines?.length){
|
||||
cSeries.setData(klines.map(k=>({time:k.time,open:k.open,high:k.high,low:k.low,close:k.close})));
|
||||
|
||||
Reference in New Issue
Block a user