fix(provider): fix anthropic integration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Conversation } from './classes.conversation.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import type { AnthropicProvider } from './provider.anthropic.js';
|
||||
import { 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';
|
||||
@@ -12,6 +12,8 @@ export interface ISmartAiOptions {
|
||||
perplexityToken?: string;
|
||||
}
|
||||
|
||||
export type TProvider = 'openai' | 'anthropic' | 'perplexity' | 'ollama';
|
||||
|
||||
export class SmartAi {
|
||||
public options: ISmartAiOptions;
|
||||
|
||||
@@ -31,21 +33,30 @@ export class SmartAi {
|
||||
});
|
||||
await this.openaiProvider.start();
|
||||
}
|
||||
if (this.options.anthropicToken) {
|
||||
this.anthropicProvider = new AnthropicProvider({
|
||||
anthropicToken: this.options.anthropicToken,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async stop() {}
|
||||
|
||||
/**
|
||||
* creates an OpenAI conversation
|
||||
* create a new conversation
|
||||
*/
|
||||
public async createOpenApiConversation() {
|
||||
const conversation = await Conversation.createWithOpenAi(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an OpenAI conversation
|
||||
*/
|
||||
public async createAnthropicConversation() {
|
||||
const conversation = await Conversation.createWithAnthropic(this);
|
||||
createConversation(provider: TProvider) {
|
||||
switch (provider) {
|
||||
case 'openai':
|
||||
return Conversation.createWithOpenAi(this);
|
||||
case 'anthropic':
|
||||
return Conversation.createWithAnthropic(this);
|
||||
case 'perplexity':
|
||||
return Conversation.createWithPerplexity(this);
|
||||
case 'ollama':
|
||||
return Conversation.createWithOllama(this);
|
||||
default:
|
||||
throw new Error('Provider not available');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user