MCPcopy Create free account
hub / github.com/SKaplanOfficial/Raycast-PromptLab / createModel

Function createModel

src/hooks/useModels.ts:54–97  ·  view source on GitHub ↗
(newData: Model & { [key: string]: string | boolean })

Source from the content-addressed store, hash-verified

52 };
53
54 const createModel = async (newData: Model & { [key: string]: string | boolean }) => {
55 // Check if the name is empty
56 if (!newData.name) {
57 setError("Name cannot be empty.");
58 return false;
59 }
60
61 // Check if a model with that name already exists
62 if (models.find((model) => model.name == newData.name)) {
63 setError("A model with that name already exists.");
64 return false;
65 }
66
67 // Create the model object
68 const newModel: Model = {
69 name: newData.name,
70 description: newData.description || "",
71 icon: newData.icon || Icon.Gear,
72 iconColor: newData.iconColor || Color.PrimaryText,
73 favorited: false,
74 endpoint: newData.endpoint || "",
75 authType: newData.authType || "",
76 apiKey: newData.apiKey || "",
77 inputSchema: newData.inputSchema || "",
78 outputKeyPath: newData.outputKeyPath || "",
79 outputTiming: newData.outputTiming || "sync",
80 lengthLimit: newData.lengthLimit || "2500",
81 id: "",
82 notes: newData.notes || "",
83 isDefault: newData.isDefault,
84 temperature: newData.temperature || "1.0",
85 };
86
87 // If this is the default model, set all other models to not be default
88 if (newData.isDefault) {
89 for (const model of models) {
90 await updateModel(model, { ...model, isDefault: false });
91 }
92 }
93
94 // Save the model
95 await LocalStorage.setItem(`--model-${newData.name}`, JSON.stringify(newModel));
96 return newModel;
97 };
98
99 const favorites = () => {
100 return models.filter((model) => model.favorited);

Callers

nothing calls this directly

Calls 1

updateModelFunction · 0.90

Tested by

no test coverage detected