ui: add logs, add threadid

This commit is contained in:
nick-delirium 2025-04-25 14:29:58 +02:00
parent efe16a7065
commit c6357e16e9
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 8 additions and 3 deletions

View file

@ -6,6 +6,7 @@ export class ChatManager {
constructor({ projectId, userId, threadId }: { projectId: string; userId: string; threadId: string }) {
this.threadId = threadId;
console.log('Kai socket', projectId, userId, threadId, window.env.KAI_TESTING);
const socket = io(`localhost:8700/kai/chat`, {
transports: ['websocket'],
autoConnect: true,
@ -27,6 +28,9 @@ export class ChatManager {
socket.on('disconnect', () => {
console.log('Disconnected from server');
});
socket.on('error', (err) => {
console.error('Socket error:', err);
})
socket.onAny((e) => console.log('event', e));
this.socket = socket;

View file

@ -35,11 +35,10 @@ function ChatLog({
const [isLoading, setLoading] = React.useState(false);
React.useEffect(() => {
console.log(threadId, initialMsg);
//const settings = { projectId: projectId ?? 2325, userId: userId ?? 65 };
const settings = { projectId: '2325', userId: '0', threadId, };
if (threadId && !initialMsg) {
setLoading(true);
//const settings = { projectId: projectId ?? 2325, userId: userId ?? 65 };
const settings = { projectId: '2325', userId: '0' };
aiService
.getKaiChat(settings.projectId, settings.userId, threadId)
.then((res) => {
@ -62,6 +61,8 @@ function ChatLog({
.finally(() => {
setLoading(false);
});
}
if (threadId) {
chatManager.current = new ChatManager(settings);
chatManager.current.setOnMsgHook({
msgCallback: (msg) => {