refactor: update provider documentation and improve comments
This commit is contained in:
@ -73,7 +73,7 @@ describe('OpenAIProvider', () => {
|
||||
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 () => {
|
||||
@ -85,7 +85,7 @@ describe('OpenAIProvider', () => {
|
||||
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 () => {
|
||||
@ -96,7 +96,7 @@ describe('OpenAIProvider', () => {
|
||||
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 () => {
|
||||
@ -107,7 +107,7 @@ describe('OpenAIProvider', () => {
|
||||
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 () => {
|
||||
@ -139,7 +139,7 @@ describe('OpenAIProvider', () => {
|
||||
|
||||
expect(providerError).toBeInstanceOf(AIProviderError);
|
||||
expect(providerError.type).toBe(AIErrorType.RATE_LIMIT);
|
||||
expect(providerError.message).toContain('Rate limit exceeded');
|
||||
expect(providerError.message).toContain('Too many requests');
|
||||
});
|
||||
|
||||
it('should handle model not found errors', () => {
|
||||
@ -255,7 +255,7 @@ describe('OpenAIProvider', () => {
|
||||
|
||||
expect(() => {
|
||||
(provider as any).formatCompletionResponse(mockResponse);
|
||||
}).toThrow('No content in OpenAI response');
|
||||
}).toThrow('No content found in OpenAI response');
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user