2025-09-28 15:06:07 +00:00
|
|
|
import { tap, expect } from '@push.rocks/tapbundle';
|
|
|
|
import * as smartai from '../ts/index.js';
|
|
|
|
|
|
|
|
// Basic instantiation tests that don't require API tokens
|
|
|
|
// These tests can run in CI/CD environments without credentials
|
|
|
|
|
|
|
|
tap.test('Basic: should create SmartAi instance', async () => {
|
|
|
|
const testSmartai = new smartai.SmartAi({
|
|
|
|
openaiToken: 'dummy-token-for-testing'
|
|
|
|
});
|
|
|
|
expect(testSmartai).toBeInstanceOf(smartai.SmartAi);
|
2025-09-28 15:51:50 +00:00
|
|
|
// Provider is only created after calling start()
|
|
|
|
expect(testSmartai.options.openaiToken).toEqual('dummy-token-for-testing');
|
2025-09-28 15:06:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate OpenAI provider', async () => {
|
|
|
|
const openaiProvider = new smartai.OpenAiProvider({
|
|
|
|
openaiToken: 'dummy-token'
|
|
|
|
});
|
|
|
|
expect(openaiProvider).toBeInstanceOf(smartai.OpenAiProvider);
|
|
|
|
expect(typeof openaiProvider.chat).toEqual('function');
|
|
|
|
expect(typeof openaiProvider.audio).toEqual('function');
|
|
|
|
expect(typeof openaiProvider.vision).toEqual('function');
|
|
|
|
expect(typeof openaiProvider.document).toEqual('function');
|
|
|
|
expect(typeof openaiProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate Anthropic provider', async () => {
|
|
|
|
const anthropicProvider = new smartai.AnthropicProvider({
|
|
|
|
anthropicToken: 'dummy-token'
|
|
|
|
});
|
|
|
|
expect(anthropicProvider).toBeInstanceOf(smartai.AnthropicProvider);
|
|
|
|
expect(typeof anthropicProvider.chat).toEqual('function');
|
|
|
|
expect(typeof anthropicProvider.audio).toEqual('function');
|
|
|
|
expect(typeof anthropicProvider.vision).toEqual('function');
|
|
|
|
expect(typeof anthropicProvider.document).toEqual('function');
|
|
|
|
expect(typeof anthropicProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate Perplexity provider', async () => {
|
|
|
|
const perplexityProvider = new smartai.PerplexityProvider({
|
|
|
|
perplexityToken: 'dummy-token'
|
|
|
|
});
|
|
|
|
expect(perplexityProvider).toBeInstanceOf(smartai.PerplexityProvider);
|
|
|
|
expect(typeof perplexityProvider.chat).toEqual('function');
|
|
|
|
expect(typeof perplexityProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate Groq provider', async () => {
|
|
|
|
const groqProvider = new smartai.GroqProvider({
|
|
|
|
groqToken: 'dummy-token'
|
|
|
|
});
|
|
|
|
expect(groqProvider).toBeInstanceOf(smartai.GroqProvider);
|
|
|
|
expect(typeof groqProvider.chat).toEqual('function');
|
|
|
|
expect(typeof groqProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate Ollama provider', async () => {
|
|
|
|
const ollamaProvider = new smartai.OllamaProvider({
|
|
|
|
baseUrl: 'http://localhost:11434'
|
|
|
|
});
|
|
|
|
expect(ollamaProvider).toBeInstanceOf(smartai.OllamaProvider);
|
|
|
|
expect(typeof ollamaProvider.chat).toEqual('function');
|
|
|
|
expect(typeof ollamaProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate xAI provider', async () => {
|
2025-09-28 15:51:50 +00:00
|
|
|
const xaiProvider = new smartai.XAIProvider({
|
2025-09-28 15:06:07 +00:00
|
|
|
xaiToken: 'dummy-token'
|
|
|
|
});
|
2025-09-28 15:51:50 +00:00
|
|
|
expect(xaiProvider).toBeInstanceOf(smartai.XAIProvider);
|
2025-09-28 15:06:07 +00:00
|
|
|
expect(typeof xaiProvider.chat).toEqual('function');
|
|
|
|
expect(typeof xaiProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: should instantiate Exo provider', async () => {
|
|
|
|
const exoProvider = new smartai.ExoProvider({
|
|
|
|
exoBaseUrl: 'http://localhost:8000'
|
|
|
|
});
|
|
|
|
expect(exoProvider).toBeInstanceOf(smartai.ExoProvider);
|
|
|
|
expect(typeof exoProvider.chat).toEqual('function');
|
|
|
|
expect(typeof exoProvider.research).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('Basic: all providers should extend MultiModalModel', async () => {
|
|
|
|
const openai = new smartai.OpenAiProvider({ openaiToken: 'test' });
|
|
|
|
const anthropic = new smartai.AnthropicProvider({ anthropicToken: 'test' });
|
|
|
|
|
|
|
|
expect(openai).toBeInstanceOf(smartai.MultiModalModel);
|
|
|
|
expect(anthropic).toBeInstanceOf(smartai.MultiModalModel);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default tap.start();
|