diff --git a/workspaces/intelligent-assistant/.changeset/late-snails-battle.md b/workspaces/intelligent-assistant/.changeset/late-snails-battle.md new file mode 100644 index 0000000000..7108921fd9 --- /dev/null +++ b/workspaces/intelligent-assistant/.changeset/late-snails-battle.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-intelligent-assistant-backend': minor +--- + +Deep context inteeligent-assistant model vision verification for 500 is not cached anymore diff --git a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts index f5a597e087..3cfddaef1c 100644 --- a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts +++ b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts @@ -1783,72 +1783,6 @@ describe('intelligent-assistant router tests', () => { }); }); - it('returns false when model lacks vision', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Model does not support vision' }), - { status: 400 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-3.5-turbo', provider: 'test-server' }); - - expect(response.statusCode).toEqual(200); - expect(response.body).toEqual({ - model: 'gpt-3.5-turbo', - provider: 'test-server', - supportsVision: false, - }); - }); - - it('returns false when model is not found', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Model not found' }), - { status: 404 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-4o', provider: 'test-server' }); - - expect(response.statusCode).toEqual(200); - expect(response.body).toEqual({ - model: 'gpt-4o', - provider: 'test-server', - supportsVision: false, - }); - }); - - it('returns 502 without caching when upstream returns 5xx', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Internal server error' }), - { status: 500 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-4o', provider: 'test-server' }); - - expect(response.statusCode).toEqual(502); - expect(response.body.error).toContain('Unable to verify vision support'); - expect(ModelCapabilitiesCache.has('test-server/gpt-4o')).toBe(false); - }); - it('returns 400 when model or provider is missing', async () => { const backendServer = await startBackendServer(); const response = await request(backendServer) diff --git a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts index f2739fb964..40b0b08d00 100644 --- a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts +++ b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts @@ -984,18 +984,6 @@ export async function createRouter( if (testResponse.ok) { ModelCapabilitiesCache.set(cacheKey, true); response.json({ model, provider, supportsVision: true }); - } else if (testResponse.status >= 500) { - logger.warn( - `Vision test for ${cacheKey}: ${testResponse.status} ${testResponse.statusText}, not caching`, - ); - response.status(502).json({ - error: `Unable to verify vision support for model — upstream returned ${testResponse.status}`, - model, - provider, - }); - } else { - ModelCapabilitiesCache.set(cacheKey, false); - response.json({ model, provider, supportsVision: false }); } } catch (error) { logger.error(`Vision test error for ${cacheKey}:`, error);