refactor(loadConfigModels): Stricter Default Model Fallback (#2239)

* chore: add TEndpoint type/typedef

* refactor(loadConfigModels.spec): stricter default model matching (fails with current impl.)

* refactor(loadConfigModels): return default models on endpoint basis and not fetch basis

* refactor: rename `uniqueKeyToNameMap` to `uniqueKeyToEndpointsMap` for clarity
This commit is contained in:
Danny Avila 2024-03-29 11:49:38 -04:00 committed by GitHub
parent 0a8118deed
commit dec7879cc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 16 deletions

View file

@ -267,6 +267,15 @@ describe('loadConfigModels', () => {
getCustomConfig.mockResolvedValue({
endpoints: {
custom: [
{
name: 'EndpointWithSameFetchKey',
apiKey: 'API_KEY',
baseURL: 'http://example.com',
models: {
fetch: true,
default: ['defaultModel1'],
},
},
{
name: 'EmptyFetchModel',
apiKey: 'API_KEY',
@ -283,14 +292,7 @@ describe('loadConfigModels', () => {
fetchModels.mockResolvedValue([]);
const result = await loadConfigModels(mockRequest);
expect(fetchModels).toHaveBeenCalledWith(
expect.objectContaining({
name: 'EmptyFetchModel',
apiKey: 'API_KEY',
}),
);
expect(fetchModels).toHaveBeenCalledTimes(1);
expect(result.EmptyFetchModel).toEqual(['defaultModel1', 'defaultModel2']);
});