Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/Oneirocom/Magick int…
Browse files Browse the repository at this point in the history
…o development
  • Loading branch information
michaelsharpe committed Jan 27, 2024
2 parents d2de51d + 556ef9e commit b290bd0
Show file tree
Hide file tree
Showing 30 changed files with 1,878 additions and 828 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Knex } from 'knex'

export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable('graphEvents', (table) => {
table.string('observer').notNullable()
table.string('observer').nullable()
})
}

Expand Down
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>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { SpellInterface } from 'server/schemas';
import { VariableNames } from './variableNames';
import { ValueType } from './ValueType';
import { DefaultConfig } from './DefaultConfig';
import { CompletionProviderOptions } from './CompletionProviderOptions';


type Props = {
tab: Tab
Expand All @@ -38,7 +40,8 @@ const ConfigurationComponents = {
eventStateProperties: EventStateProperties,
variableNames: VariableNames,
valueType: ValueType,
default: DefaultConfig
default: DefaultConfig,
modelProviders: CompletionProviderOptions,
}

export const PropertiesWindow = (props: Props) => {
Expand All @@ -47,6 +50,7 @@ export const PropertiesWindow = (props: Props) => {
const selectedNode = useSelector(selectActiveNode(props.tab.id))
const handleChange = useChangeNodeData(selectedNode?.id);


if (!selectedNode) return null

const spec = nodeSpecs.find(spec => spec.type === selectedNode.type)
Expand Down Expand Up @@ -109,4 +113,4 @@ export const PropertiesWindow = (props: Props) => {
}) as any}
</Window>
)
}
}
Loading

0 comments on commit b290bd0

Please sign in to comment.