zhlajiex
commited on
Commit
·
9ddb9ef
1
Parent(s):
cfc37b7
Fix: Resolve broken image display by correcting file paths and adding CSS styling
Browse files- backend/controllers/ai.js +9 -6
- backend/public/chat.html +1 -0
backend/controllers/ai.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const fs = require('fs');
|
|
|
|
| 3 |
const { Client } = require('@gradio/client');
|
| 4 |
const User = require('../models/User');
|
| 5 |
const ChatSession = require('../models/ChatSession');
|
|
@@ -168,12 +169,14 @@ exports.chat = asyncHandler(async (req, res, next) => {
|
|
| 168 |
timeout: 30000
|
| 169 |
}
|
| 170 |
);
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
| 177 |
|
| 178 |
await Message.create({ sessionId: session._id, sender: 'user', content: message, attachmentUrl: '' });
|
| 179 |
await Message.create({ sessionId: session._id, sender: 'ai', content: aiResponse, modelUsed: activeModelName });
|
|
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const fs = require('fs');
|
| 3 |
+
const path = require('path');
|
| 4 |
const { Client } = require('@gradio/client');
|
| 5 |
const User = require('../models/User');
|
| 6 |
const ChatSession = require('../models/ChatSession');
|
|
|
|
| 169 |
timeout: 30000
|
| 170 |
}
|
| 171 |
);
|
| 172 |
+
const filename = `vision-${Date.now()}.png`;
|
| 173 |
+
const uploadsDir = path.join(__dirname, '..', 'public', 'uploads');
|
| 174 |
+
const filepath = path.join(uploadsDir, filename);
|
| 175 |
+
|
| 176 |
+
if (!fs.existsSync(uploadsDir)) fs.mkdirSync(uploadsDir, { recursive: true });
|
| 177 |
+
|
| 178 |
+
fs.writeFileSync(filepath, response.data);
|
| 179 |
+
const imageUrl = `/uploads/${filename}`; const aiResponse = `[VISUAL_PROJECTION_COMPLETE]\n\n`;
|
| 180 |
|
| 181 |
await Message.create({ sessionId: session._id, sender: 'user', content: message, attachmentUrl: '' });
|
| 182 |
await Message.create({ sessionId: session._id, sender: 'ai', content: aiResponse, modelUsed: activeModelName });
|
backend/public/chat.html
CHANGED
|
@@ -60,6 +60,7 @@
|
|
| 60 |
.ai .status-dot { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
|
| 61 |
|
| 62 |
.prose { font-size: 14px; line-height: 1.6; color: rgba(255,255,255,0.9); overflow-wrap: break-word; word-break: break-word; }
|
|
|
|
| 63 |
.prose pre { background: rgba(0,0,0,0.5) !important; padding: 1rem !important; border-radius: 1rem !important; border: 1px solid var(--border) !important; margin: 1rem 0 !important; overflow-x: auto !important; position: relative; }
|
| 64 |
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 12px; }
|
| 65 |
.prose th, .prose td { border: 1px solid var(--border); padding: 8px; text-align: left; }
|
|
|
|
| 60 |
.ai .status-dot { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
|
| 61 |
|
| 62 |
.prose { font-size: 14px; line-height: 1.6; color: rgba(255,255,255,0.9); overflow-wrap: break-word; word-break: break-word; }
|
| 63 |
+
.prose img { max-width: 100%; height: auto; border-radius: 1rem; border: 1px solid var(--border); margin: 1rem 0; box-shadow: 0 10px 30px rgba(0,0,0,0.5); cursor: zoom-in; display: block; }
|
| 64 |
.prose pre { background: rgba(0,0,0,0.5) !important; padding: 1rem !important; border-radius: 1rem !important; border: 1px solid var(--border) !important; margin: 1rem 0 !important; overflow-x: auto !important; position: relative; }
|
| 65 |
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 12px; }
|
| 66 |
.prose th, .prose td { border: 1px solid var(--border); padding: 8px; text-align: left; }
|