refactor: update provider documentation and improve comments
This commit is contained in:
@ -59,12 +59,11 @@ describe('GeminiProvider', () => {
|
||||
expect(info.models).toContain('gemini-1.5-flash');
|
||||
expect(info.models).toContain('gemini-1.5-pro');
|
||||
expect(info.models).toContain('gemini-1.0-pro');
|
||||
expect(info.maxContextLength).toBe(1000000);
|
||||
expect(info.maxContextLength).toBe(1048576);
|
||||
expect(info.capabilities).toHaveProperty('vision', true);
|
||||
expect(info.capabilities).toHaveProperty('functionCalling', true);
|
||||
expect(info.capabilities).toHaveProperty('systemMessages', true);
|
||||
expect(info.capabilities).toHaveProperty('multimodal', true);
|
||||
expect(info.capabilities).toHaveProperty('largeContext', true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -80,7 +79,7 @@ describe('GeminiProvider', () => {
|
||||
messages: [{ role: 'user', content: 'test' }],
|
||||
temperature: 1.5
|
||||
})
|
||||
).rejects.toThrow('Temperature must be between 0.0 and 1.0');
|
||||
).rejects.toThrow('Temperature must be a number between 0.0 and 1.0');
|
||||
});
|
||||
|
||||
it('should validate top_p range', async () => {
|
||||
@ -93,7 +92,7 @@ describe('GeminiProvider', () => {
|
||||
messages: [{ role: 'user', content: 'test' }],
|
||||
topP: 1.5
|
||||
})
|
||||
).rejects.toThrow('Top-p must be between 0.0 and 1.0');
|
||||
).rejects.toThrow('Top-p must be a number between 0.0 (exclusive) and 1.0 (inclusive)');
|
||||
});
|
||||
|
||||
it('should validate message format', async () => {
|
||||
@ -105,7 +104,7 @@ describe('GeminiProvider', () => {
|
||||
provider.complete({
|
||||
messages: [{ role: 'invalid' as any, content: 'test' }]
|
||||
})
|
||||
).rejects.toThrow('Each message must have a valid role');
|
||||
).rejects.toThrow('Message at index 0 has invalid role \'invalid\'. Must be: system, user, assistant');
|
||||
});
|
||||
|
||||
it('should validate empty content', async () => {
|
||||
@ -117,7 +116,7 @@ describe('GeminiProvider', () => {
|
||||
provider.complete({
|
||||
messages: [{ role: 'user', content: '' }]
|
||||
})
|
||||
).rejects.toThrow('Each message must have non-empty string content');
|
||||
).rejects.toThrow('Message at index 0 must have non-empty string content');
|
||||
});
|
||||
|
||||
it('should require initialization before use', async () => {
|
||||
@ -137,7 +136,7 @@ describe('GeminiProvider', () => {
|
||||
|
||||
expect(providerError).toBeInstanceOf(AIProviderError);
|
||||
expect(providerError.type).toBe(AIErrorType.AUTHENTICATION);
|
||||
expect(providerError.message).toContain('Authentication failed');
|
||||
expect(providerError.message).toContain('Invalid Google API key');
|
||||
});
|
||||
|
||||
it('should handle rate limit errors', () => {
|
||||
@ -147,7 +146,7 @@ describe('GeminiProvider', () => {
|
||||
|
||||
expect(providerError).toBeInstanceOf(AIProviderError);
|
||||
expect(providerError.type).toBe(AIErrorType.RATE_LIMIT);
|
||||
expect(providerError.message).toContain('Rate limit exceeded');
|
||||
expect(providerError.message).toContain('API quota exceeded');
|
||||
});
|
||||
|
||||
it('should handle model not found errors', () => {
|
||||
@ -161,7 +160,7 @@ describe('GeminiProvider', () => {
|
||||
});
|
||||
|
||||
it('should handle invalid request errors', () => {
|
||||
const error = new Error('invalid request parameters');
|
||||
const error = new Error('invalid length request parameters');
|
||||
|
||||
const providerError = (provider as any).handleGeminiError(error);
|
||||
|
||||
@ -351,7 +350,7 @@ describe('GeminiProvider', () => {
|
||||
|
||||
expect(() => {
|
||||
(provider as any).formatCompletionResponse(mockResponse, 'gemini-1.5-flash');
|
||||
}).toThrow('No content in Gemini response');
|
||||
}).toThrow('No candidates found in Gemini response');
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user