From 62085b40adf75f97aa123b7481235bab0017d255 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 11:52:18 +0100 Subject: [PATCH] move model configuration to the ps-model package --- packages/@pufflig/ps-models/src/index.ts | 17 ++++++++++++++++- .../adapters/document_check/document_check.ts | 4 ++-- .../src/adapters/llm/llm_completion.ts | 5 ++--- .../src/adapters/openai/openai_completion.ts | 5 ++--- .../@pufflig/ps-nodes-config/src/constants.ts | 17 ----------------- .../ps-nodes-config/src/data/model/model.ts | 7 +++---- 6 files changed, 25 insertions(+), 30 deletions(-) delete mode 100644 packages/@pufflig/ps-nodes-config/src/constants.ts diff --git a/packages/@pufflig/ps-models/src/index.ts b/packages/@pufflig/ps-models/src/index.ts index 2fad08c..e4cabd2 100644 --- a/packages/@pufflig/ps-models/src/index.ts +++ b/packages/@pufflig/ps-models/src/index.ts @@ -1,3 +1,4 @@ +import { ModelConfig } from "@pufflig/ps-types"; import { hf_completion, hf_settings } from "./models/hf"; import { open_router_completion, open_router_settings } from "./models/open_router"; import { openai_chat, openai_completion, openai_embedding, openai_settings } from "./models/openai"; @@ -5,7 +6,6 @@ import { openai_chat, openai_completion, openai_embedding, openai_settings } fro export const chat_models = { ...openai_chat }; export const completion_models = { ...openai_completion, ...open_router_completion, ...hf_completion }; export const embedding_models = { ...openai_embedding }; -export const models = { ...openai_chat, ...openai_completion, ...open_router_completion, ...hf_completion }; // provider settings export const settings = [...openai_settings, ...hf_settings, ...open_router_settings]; @@ -40,3 +40,18 @@ export const openai = { }; export const default_completion_model = "gpt-3.5-turbo-instruct"; +export const default_assistant_model = "gpt-4-1106-preview"; + +export const available_models = [ + "gpt-3.5-turbo-instruct", + "gpt-4-1106-preview", + "anthropic/claude-2", + "meta-llama/llama-2-13b-chat", +]; + +export const models = Object.entries({ ...completion_models, ...chat_models }) + .filter(([modelId]) => available_models.includes(modelId)) + .reduce((acc, [modelId, model]) => { + acc[modelId] = model; + return acc; + }, {} as Record); diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts index 127db39..3a5ed39 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts @@ -1,5 +1,5 @@ +import { default_completion_model, models } from "@pufflig/ps-models"; import { NodeConfig } from "@pufflig/ps-types"; -import { default_model, models } from "../../constants"; export const documentCheckNodeType = "modifier/document_check" as const; @@ -38,7 +38,7 @@ export const documentCheck: NodeConfig = { type: "model", definition: models, defaultValue: { - modelId: default_model, + modelId: default_completion_model, parameters: {}, }, }, diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/llm/llm_completion.ts b/packages/@pufflig/ps-nodes-config/src/adapters/llm/llm_completion.ts index 4f0660b..fcf5c48 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/llm/llm_completion.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/llm/llm_completion.ts @@ -1,6 +1,5 @@ -import { models } from "@pufflig/ps-models"; +import { default_completion_model, models } from "@pufflig/ps-models"; import { NodeConfig } from "@pufflig/ps-types"; -import { default_model } from "../../constants"; export const llmCompletionNodeType = "adapter/llm_completion" as const; @@ -40,7 +39,7 @@ export const llmCompletionConfig: NodeConfig = { type: "model", definition: models, defaultValue: { - modelId: default_model, + modelId: default_completion_model, parameters: {}, }, }, diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/openai/openai_completion.ts b/packages/@pufflig/ps-nodes-config/src/adapters/openai/openai_completion.ts index 1e0cf7e..5681487 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/openai/openai_completion.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/openai/openai_completion.ts @@ -1,6 +1,5 @@ -import { openai, OPENAI_API_KEY } from "@pufflig/ps-models"; +import { default_completion_model, openai, OPENAI_API_KEY } from "@pufflig/ps-models"; import { NodeConfig } from "@pufflig/ps-types"; -import { default_model } from "../../constants"; export const openaiCompletionConfig: NodeConfig = { name: "OpenAI (Completion)", @@ -45,7 +44,7 @@ export const openaiCompletionConfig: NodeConfig = { type: "model", definition: openai.completion_models, defaultValue: { - modelId: default_model, + modelId: default_completion_model, parameters: {}, }, }, diff --git a/packages/@pufflig/ps-nodes-config/src/constants.ts b/packages/@pufflig/ps-nodes-config/src/constants.ts deleted file mode 100644 index 76ec5fd..0000000 --- a/packages/@pufflig/ps-nodes-config/src/constants.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { chat_models, completion_models } from "@pufflig/ps-models"; - -export const default_model = "gpt-3.5-turbo-instruct"; - -export const available_models = [ - "gpt-3.5-turbo-instruct", - "gpt-4-1106-preview", - "anthropic/claude-2", - "meta-llama/llama-2-13b-chat", -]; - -export const models = Object.values({ ...completion_models, ...chat_models }) - .filter((model) => available_models.includes(model.modelId)) - .reduce((acc, model) => { - acc[model.modelId] = model; - return acc; - }, {} as Record); diff --git a/packages/@pufflig/ps-nodes-config/src/data/model/model.ts b/packages/@pufflig/ps-nodes-config/src/data/model/model.ts index 2779c83..1b4fbef 100644 --- a/packages/@pufflig/ps-nodes-config/src/data/model/model.ts +++ b/packages/@pufflig/ps-nodes-config/src/data/model/model.ts @@ -1,6 +1,5 @@ +import { default_completion_model, models } from "@pufflig/ps-models"; import { NodeConfig } from "@pufflig/ps-types"; -import { default_model } from "../../constants"; -import { models } from "@pufflig/ps-models"; export const modelNodeType = "data/model" as const; @@ -17,7 +16,7 @@ export const model: NodeConfig = { type: "model", definition: { ...models }, defaultValue: { - modelId: default_model, + modelId: default_completion_model, parameters: {}, }, }, @@ -28,7 +27,7 @@ export const model: NodeConfig = { name: "Model Name", description: "The name of the model to use.", type: "selection", - defaultValue: default_model, + defaultValue: default_completion_model, options: Object.keys({ ...models }).map((modelId) => ({ id: modelId, name: modelId,