Skip to content

Commit

Permalink
move model configuration to the ps-model package
Browse files Browse the repository at this point in the history
  • Loading branch information
au-re committed Nov 23, 2023
1 parent 2562bde commit 62085b4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
17 changes: 16 additions & 1 deletion packages/@pufflig/ps-models/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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";

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];
Expand Down Expand Up @@ -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<string, ModelConfig>);
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -38,7 +38,7 @@ export const documentCheck: NodeConfig = {
type: "model",
definition: models,
defaultValue: {
modelId: default_model,
modelId: default_completion_model,
parameters: {},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -40,7 +39,7 @@ export const llmCompletionConfig: NodeConfig = {
type: "model",
definition: models,
defaultValue: {
modelId: default_model,
modelId: default_completion_model,
parameters: {},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down Expand Up @@ -45,7 +44,7 @@ export const openaiCompletionConfig: NodeConfig = {
type: "model",
definition: openai.completion_models,
defaultValue: {
modelId: default_model,
modelId: default_completion_model,
parameters: {},
},
},
Expand Down
17 changes: 0 additions & 17 deletions packages/@pufflig/ps-nodes-config/src/constants.ts

This file was deleted.

7 changes: 3 additions & 4 deletions packages/@pufflig/ps-nodes-config/src/data/model/model.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,7 +16,7 @@ export const model: NodeConfig = {
type: "model",
definition: { ...models },
defaultValue: {
modelId: default_model,
modelId: default_completion_model,
parameters: {},
},
},
Expand All @@ -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,
Expand Down

0 comments on commit 62085b4

Please sign in to comment.