mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
🦙 feat: Ollama Vision Support (#2643)
* refactor: checkVisionRequest, search availableModels for valid vision model instead of using default * feat: install ollama-js, add typedefs * feat: Ollama Vision Support * ci: fix test
This commit is contained in:
parent
3c5fa40435
commit
c94278be85
12 changed files with 390 additions and 117 deletions
|
@ -1,7 +1,7 @@
|
|||
const axios = require('axios');
|
||||
const { logger } = require('~/config');
|
||||
|
||||
const { fetchModels, getOpenAIModels, deriveBaseURL } = require('./ModelService');
|
||||
const { fetchModels, getOpenAIModels } = require('./ModelService');
|
||||
jest.mock('~/utils', () => {
|
||||
const originalUtils = jest.requireActual('~/utils');
|
||||
return {
|
||||
|
@ -329,47 +329,3 @@ describe('fetchModels with Ollama specific logic', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('deriveBaseURL', () => {
|
||||
it('should extract the base URL correctly from a full URL with a port', () => {
|
||||
const fullURL = 'https://example.com:8080/path?query=123';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('https://example.com:8080');
|
||||
});
|
||||
|
||||
it('should extract the base URL correctly from a full URL without a port', () => {
|
||||
const fullURL = 'https://example.com/path?query=123';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('https://example.com');
|
||||
});
|
||||
|
||||
it('should handle URLs using the HTTP protocol', () => {
|
||||
const fullURL = 'http://example.com:3000/path?query=123';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('http://example.com:3000');
|
||||
});
|
||||
|
||||
it('should return only the protocol and hostname if no port is specified', () => {
|
||||
const fullURL = 'http://example.com/path?query=123';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('http://example.com');
|
||||
});
|
||||
|
||||
it('should handle URLs with uncommon protocols', () => {
|
||||
const fullURL = 'ftp://example.com:2121/path?query=123';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('ftp://example.com:2121');
|
||||
});
|
||||
|
||||
it('should handle edge case where URL ends with a slash', () => {
|
||||
const fullURL = 'https://example.com/';
|
||||
const baseURL = deriveBaseURL(fullURL);
|
||||
expect(baseURL).toEqual('https://example.com');
|
||||
});
|
||||
|
||||
it('should return the original URL if the URL is invalid', () => {
|
||||
const invalidURL = 'htp:/example.com:8080';
|
||||
const result = deriveBaseURL(invalidURL);
|
||||
expect(result).toBe(invalidURL);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue