zhlajiex
commited on
Commit
·
cfc37b7
1
Parent(s):
d67a7b5
Fix: Explicitly set Accept: image/png for Vision core to resolve Link Failure
Browse files- backend/controllers/ai.js +12 -10
backend/controllers/ai.js
CHANGED
|
@@ -156,16 +156,18 @@ exports.chat = asyncHandler(async (req, res, next) => {
|
|
| 156 |
console.log(`[Vision] Projecting via ${apiModelId}...`);
|
| 157 |
|
| 158 |
try {
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
| 169 |
const filename = `vision-${Date.now()}.png`;
|
| 170 |
const filepath = `./public/uploads/${filename}`;
|
| 171 |
if (!fs.existsSync('./public/uploads')) fs.mkdirSync('./public/uploads', { recursive: true });
|
|
|
|
| 156 |
console.log(`[Vision] Projecting via ${apiModelId}...`);
|
| 157 |
|
| 158 |
try {
|
| 159 |
+
const response = await axios.post(
|
| 160 |
+
`https://router.huggingface.co/hf-inference/models/${apiModelId}`,
|
| 161 |
+
{ inputs: prompt },
|
| 162 |
+
{
|
| 163 |
+
headers: {
|
| 164 |
+
Authorization: `Bearer ${hfToken}`,
|
| 165 |
+
'Accept': 'image/png'
|
| 166 |
+
},
|
| 167 |
+
responseType: 'arraybuffer',
|
| 168 |
+
timeout: 30000
|
| 169 |
+
}
|
| 170 |
+
);
|
| 171 |
const filename = `vision-${Date.now()}.png`;
|
| 172 |
const filepath = `./public/uploads/${filename}`;
|
| 173 |
if (!fs.existsSync('./public/uploads')) fs.mkdirSync('./public/uploads', { recursive: true });
|