Skip to content

Commit

Permalink
Update providers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zachey01 committed Jul 24, 2024
1 parent b3ebd42 commit e55f3df
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/providers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"use strict";
import AryahcrProvider from "./Providers/ChatCompletion/Aryahcr.js";
import BlackBoxProvider from "./Providers/ChatCompletion/BlackBox.js";
import NextwayProvider from "./Providers/ChatCompletion/Nextway.js";
Expand All @@ -10,30 +9,25 @@ import ChatBotRuProvider from "./Providers/ChatCompletion/ChatBotRu.js";
import DALLE2Provider from "./Providers/ImageGeneration/DALLE.js";
import StableDiffusionProvider from "./Providers/ImageGeneration/StableDiffusion.js";

const PROVIDERS = {
Aryahcr: AryahcrProvider,
BlackBox: BlackBoxProvider,
Nextway: NextwayProvider,
Chrome: ChromeProvider,
Ollama: OllamaProvider,
Alibaba: AlibabaProvider,
ChatBotRu: ChatBotRuProvider,
DALLE2: DALLE2Provider,
StableDiffusion: StableDiffusionProvider
};

class GPT4js {
static createProvider(providerName) {
switch (providerName) {
case "Aryahcr":
return new AryahcrProvider();
case "BlackBox":
return new BlackBoxProvider();
case "Nextway":
return new NextwayProvider();
case "Chrome":
return new ChromeProvider();
case "Ollama":
return new OllamaProvider();
case "Alibaba":
return new AlibabaProvider();
case "ChatBotRu":
return new ChatBotRuProvider();
case "DALLE2":
return new DALLE2Provider();
case "StableDiffusion":
return new StableDiffusionProvider();
default:
throw new Error(`Provider ${providerName} is not supported.`);
const Provider = PROVIDERS[providerName];
if (!Provider) {
throw new Error(`Provider ${providerName} is not supported.`);
}
return new Provider();
}
}

Expand Down

0 comments on commit e55f3df

Please sign in to comment.