-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/Oneirocom/Magick int…
…o development
- Loading branch information
Showing
30 changed files
with
1,878 additions
and
828 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
packages/client/editor/src/components/PropertiesWindow/CompletionProviderOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { ConfigurationComponentProps } from "./PropertiesWindow"; | ||
|
||
import { | ||
allOpenAICompletionModelsArray, | ||
googleAIStudioModelsArray, | ||
togetherAIModelsArray, | ||
// ai21ModelsArray, | ||
// alephAlphaModelsArray, | ||
// anthropicModelsArray, | ||
// anyscaleModelsArray, | ||
// baseTenModelsArray, | ||
// bedrockModelsArray, | ||
// cloudflareWorkersAIModelsArray, | ||
// deepInfraChatModelsArray, | ||
// huggingFaceModelsWithPromptFormattingArray, | ||
// mistralAIModelsArray, | ||
// nlpCloudModelsArray, | ||
// ollamaModelsArray, | ||
// openRouterModelsArray, | ||
// palmModelsArray, | ||
// perplexityAIModelsArray, | ||
// petalsModelsArray, | ||
// replicateModelsArray, | ||
// sageMakerModelsArray, | ||
// vertexAIGoogleModelsArray, | ||
// vllmModelsArray, | ||
// voyageAIModelsArray, | ||
// xinferenceModelsArray | ||
} from "plugins/core/src/lib/services/coreLLMService/constants/completionModelArrays"; | ||
import { CompletionModels } from "plugins/core/src/lib/services/coreLLMService/types/completionModels"; | ||
import { LLMProviders } from 'plugins/core/src/lib/services/coreLLMService/types/providerTypes'; | ||
import { ActiveProviders, activeProviders } from "plugins/core/src/lib/services/coreLLMService/constants/providers"; | ||
|
||
export const CompletionProviderOptions = (props: ConfigurationComponentProps) => { | ||
const [selectedProvider, setSelectedProvider] = useState<ActiveProviders>(props.fullConfig.modelProvider); | ||
const [selectedModel, setSelectedModel] = useState<CompletionModels | null>(props.fullConfig.model); | ||
const [filteredModels, setFilteredModels] = useState<CompletionModels[]>([]); | ||
|
||
useEffect(() => { | ||
// get all completion models for the selected provider` | ||
switch (selectedProvider) { | ||
case LLMProviders.OpenAI: | ||
setFilteredModels(allOpenAICompletionModelsArray); | ||
break; | ||
case LLMProviders.GoogleAIStudio: | ||
setFilteredModels(googleAIStudioModelsArray); | ||
break; | ||
case LLMProviders.TogetherAI: | ||
setFilteredModels(togetherAIModelsArray); | ||
break; | ||
// case LLMProviders.VertexAI: | ||
// setFilteredModels(vertexAIGoogleModelsArray); | ||
// break; | ||
// case LLMProviders.AI21: | ||
// setFilteredModels(ai21ModelsArray); | ||
// break; | ||
// case LLMProviders.Anthropic: | ||
// setFilteredModels(anthropicModelsArray); | ||
// break; | ||
// case LLMProviders.AlephAlpha: | ||
// setFilteredModels(alephAlphaModelsArray); | ||
// break; | ||
// case LLMProviders.Anyscale: | ||
// setFilteredModels(anyscaleModelsArray); | ||
// break; | ||
// case LLMProviders.Baseten: | ||
// setFilteredModels(baseTenModelsArray); | ||
// break; | ||
// case LLMProviders.Bedrock: | ||
// setFilteredModels(bedrockModelsArray); | ||
// break; | ||
// case LLMProviders.CloudflareWorkersAI: | ||
// setFilteredModels(cloudflareWorkersAIModelsArray); | ||
// break; | ||
// case LLMProviders.DeepInfra: | ||
// setFilteredModels(deepInfraChatModelsArray); | ||
// break; | ||
// case LLMProviders.HuggingFace: | ||
// setFilteredModels(huggingFaceModelsWithPromptFormattingArray); | ||
// break; | ||
// case LLMProviders.Mistral: | ||
// setFilteredModels(mistralAIModelsArray); | ||
// break; | ||
// case LLMProviders.NLPCloud: | ||
// setFilteredModels(nlpCloudModelsArray); | ||
// break; | ||
// case LLMProviders.Ollama: | ||
// setFilteredModels(ollamaModelsArray); | ||
// break; | ||
// case LLMProviders.OpenRouter: | ||
// setFilteredModels(openRouterModelsArray); | ||
// break; | ||
// case LLMProviders.Palm: | ||
// setFilteredModels(palmModelsArray); | ||
// break; | ||
// case LLMProviders.PerplexityAI: | ||
// setFilteredModels(perplexityAIModelsArray); | ||
// break; | ||
// case LLMProviders.Petals: | ||
// setFilteredModels(petalsModelsArray); | ||
// break; | ||
// case LLMProviders.Replicate: | ||
// setFilteredModels(replicateModelsArray); | ||
// break; | ||
// case LLMProviders.Sagemaker: | ||
// setFilteredModels(sageMakerModelsArray); | ||
// break; | ||
// case LLMProviders.VLLM: | ||
// setFilteredModels(vllmModelsArray); | ||
// break; | ||
// case LLMProviders.VoyageAI: | ||
// setFilteredModels(voyageAIModelsArray); | ||
// break; | ||
// case LLMProviders.Xinference: | ||
// setFilteredModels(xinferenceModelsArray); | ||
// break; | ||
default: setFilteredModels([]); | ||
} | ||
}, [selectedProvider]); | ||
|
||
const onProviderChange = (provider: ActiveProviders) => { | ||
setSelectedProvider(provider); | ||
props.updateConfigKey("modelProvider", provider); | ||
}; | ||
|
||
const onModelChange = (model: CompletionModels) => { | ||
setSelectedModel(model); | ||
props.updateConfigKey("model", model); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h3>Model Provider</h3> | ||
<div className="flex flex-col mt-1"> | ||
<select | ||
className="bg-gray-600 disabled:bg-gray-700 w-full py-1 px-2 nodrag text-sm" | ||
value={selectedProvider} | ||
onChange={(e) => onProviderChange(e.currentTarget.value as ActiveProviders)} | ||
> | ||
{activeProviders.map((provider) => ( | ||
<option key={provider} value={provider}>{provider}</option> | ||
))} | ||
</select> | ||
</div> | ||
<br /> | ||
<h3>Model</h3> | ||
<div className="flex flex-col mt-1"> | ||
<select | ||
className="bg-gray-600 disabled:bg-gray-700 w-full py-1 px-2 nodrag text-sm" | ||
value={selectedModel} | ||
onChange={(e) => onModelChange(e.target.value as CompletionModels)} | ||
disabled={filteredModels.length === 0} | ||
> | ||
{filteredModels.map((model) => ( | ||
<option key={model} value={model}>{model}</option> | ||
))} | ||
</select> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.