Spaces:
Sleeping
Sleeping
Update views/Advisor.tsx
Browse files- views/Advisor.tsx +8 -9
views/Advisor.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
-
|
| 2 |
import React, { useState, useRef, useEffect } from 'react';
|
| 3 |
import {
|
| 4 |
-
Send, User, Bot, Sparkles, Loader2, Volume2, VolumeX,
|
| 5 |
} from 'lucide-react';
|
| 6 |
-
import { speakText,
|
| 7 |
import { apiClient } from '../services/api';
|
| 8 |
|
| 9 |
interface Message {
|
|
@@ -50,10 +49,10 @@ const Advisor: React.FC = () => {
|
|
| 50 |
|
| 51 |
try {
|
| 52 |
const context = { system: "LUMINA_ADVISORY_NODE" };
|
| 53 |
-
const
|
| 54 |
|
| 55 |
let fullContent = '';
|
| 56 |
-
for
|
| 57 |
fullContent += chunk.text || '';
|
| 58 |
setMessages(prev => prev.map(m => m.id === assistantMsgId ? { ...m, content: fullContent } : m));
|
| 59 |
}
|
|
@@ -64,7 +63,7 @@ const Advisor: React.FC = () => {
|
|
| 64 |
|
| 65 |
if (voiceEnabled) speakText(fullContent);
|
| 66 |
} catch (error) {
|
| 67 |
-
setMessages(prev => prev.map(m => m.id === assistantMsgId ? { ...m, content: "Neural signal lost.
|
| 68 |
} finally {
|
| 69 |
setLoading(false);
|
| 70 |
}
|
|
@@ -80,7 +79,7 @@ const Advisor: React.FC = () => {
|
|
| 80 |
</div>
|
| 81 |
<div>
|
| 82 |
<h3 className="text-white font-black italic tracking-tighter uppercase text-xl">Nexus_Core</h3>
|
| 83 |
-
<p className="text-[10px] text-zinc-500 font-black uppercase tracking-widest">
|
| 84 |
</div>
|
| 85 |
</div>
|
| 86 |
<div className="space-y-4 flex-1 overflow-y-auto pr-3 custom-scrollbar relative z-10">
|
|
@@ -115,7 +114,7 @@ const Advisor: React.FC = () => {
|
|
| 115 |
</div>
|
| 116 |
<div className={`p-8 rounded-[2.5rem] ${m.role === 'user' ? 'bg-zinc-900 text-zinc-100 rounded-tr-none border border-zinc-800' : 'bg-black border border-zinc-800 text-zinc-300 rounded-tl-none shadow-2xl'}`}>
|
| 117 |
<div className="text-base font-medium leading-relaxed tracking-tight whitespace-pre-wrap">
|
| 118 |
-
{m.content || (m.isStreaming ? "
|
| 119 |
</div>
|
| 120 |
</div>
|
| 121 |
</div>
|
|
@@ -136,4 +135,4 @@ const Advisor: React.FC = () => {
|
|
| 136 |
);
|
| 137 |
};
|
| 138 |
|
| 139 |
-
export default Advisor;
|
|
|
|
|
|
|
| 1 |
import React, { useState, useRef, useEffect } from 'react';
|
| 2 |
import {
|
| 3 |
+
Send, User, Bot, Sparkles, Loader2, Volume2, VolumeX, ChevronRight
|
| 4 |
} from 'lucide-react';
|
| 5 |
+
import { speakText, getFinancialAdviceStream } from '../services/geminiService';
|
| 6 |
import { apiClient } from '../services/api';
|
| 7 |
|
| 8 |
interface Message {
|
|
|
|
| 49 |
|
| 50 |
try {
|
| 51 |
const context = { system: "LUMINA_ADVISORY_NODE" };
|
| 52 |
+
const responseArray = await getFinancialAdviceStream(query, context);
|
| 53 |
|
| 54 |
let fullContent = '';
|
| 55 |
+
for (const chunk of responseArray) {
|
| 56 |
fullContent += chunk.text || '';
|
| 57 |
setMessages(prev => prev.map(m => m.id === assistantMsgId ? { ...m, content: fullContent } : m));
|
| 58 |
}
|
|
|
|
| 63 |
|
| 64 |
if (voiceEnabled) speakText(fullContent);
|
| 65 |
} catch (error) {
|
| 66 |
+
setMessages(prev => prev.map(m => m.id === assistantMsgId ? { ...m, content: "Neural signal lost. Connection refused by proxy.", isStreaming: false } : m));
|
| 67 |
} finally {
|
| 68 |
setLoading(false);
|
| 69 |
}
|
|
|
|
| 79 |
</div>
|
| 80 |
<div>
|
| 81 |
<h3 className="text-white font-black italic tracking-tighter uppercase text-xl">Nexus_Core</h3>
|
| 82 |
+
<p className="text-[10px] text-zinc-500 font-black uppercase tracking-widest">Protocol: Proxy</p>
|
| 83 |
</div>
|
| 84 |
</div>
|
| 85 |
<div className="space-y-4 flex-1 overflow-y-auto pr-3 custom-scrollbar relative z-10">
|
|
|
|
| 114 |
</div>
|
| 115 |
<div className={`p-8 rounded-[2.5rem] ${m.role === 'user' ? 'bg-zinc-900 text-zinc-100 rounded-tr-none border border-zinc-800' : 'bg-black border border-zinc-800 text-zinc-300 rounded-tl-none shadow-2xl'}`}>
|
| 116 |
<div className="text-base font-medium leading-relaxed tracking-tight whitespace-pre-wrap">
|
| 117 |
+
{m.content || (m.isStreaming ? "Connecting to Proxy..." : "Establishing link...")}
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
</div>
|
|
|
|
| 135 |
);
|
| 136 |
};
|
| 137 |
|
| 138 |
+
export default Advisor;
|