smartai/ts/classes.smartai.ts
2024-04-27 12:47:49 +02:00

51 lines
1.3 KiB
TypeScript

import { Conversation } from './classes.conversation.js';
import * as plugins from './plugins.js';
import type { AnthropicProvider } from './provider.anthropic.js';
import type { OllamaProvider } from './provider.ollama.js';
import { OpenAiProvider } from './provider.openai.js';
import type { PerplexityProvider } from './provider.perplexity.js';
export interface ISmartAiOptions {
openaiToken?: string;
anthropicToken?: string;
perplexityToken?: string;
}
export class SmartAi {
public options: ISmartAiOptions;
public openaiProvider: OpenAiProvider;
public anthropicProvider: AnthropicProvider;
public perplexityProvider: PerplexityProvider;
public ollamaProvider: OllamaProvider;
constructor(optionsArg: ISmartAiOptions) {
this.options = optionsArg;
}
public async start() {
if (this.options.openaiToken) {
this.openaiProvider = new OpenAiProvider({
openaiToken: this.options.openaiToken,
});
await this.openaiProvider.start();
}
}
public async stop() {}
/**
* creates an OpenAI conversation
*/
public async createOpenApiConversation() {
const conversation = await Conversation.createWithOpenAi(this);
}
/**
* creates an OpenAI conversation
*/
public async createAnthropicConversation() {
const conversation = await Conversation.createWithAnthropic(this);
}
}