import { Notice } from "obsidian"; import * as React from "react"; import { useState } from "react"; import { InfioSettings, } from '../types/settings'; import { checkForErrors } from "../utils/auto-complete"; import CheckBoxSettingItem from "./components/CheckBoxSettingItem"; import FewShotExampleSettings from "./components/FewShotExampleSettings"; import SettingsItem from "./components/SettingsItem"; import SliderSettingsItem from "./components/SliderSettingsItem"; import TextSettingItem from "./components/TextSettingItem"; import TriggerSettings from "./components/TriggerSettings"; import { MAX_DELAY, MAX_FREQUENCY_PENALTY, MAX_MAX_CHAR_LIMIT, MAX_MAX_TOKENS, MAX_PRESENCE_PENALTY, MAX_TEMPERATURE, MAX_TOP_P, MIN_DELAY, MIN_FREQUENCY_PENALTY, MIN_MAX_CHAR_LIMIT, MIN_MAX_TOKENS, MIN_PRESENCE_PENALTY, MIN_TEMPERATURE, MIN_TOP_P } from "./versions"; interface IProps { onSettingsChanged(settings: InfioSettings): void; settings: InfioSettings; } export default function AutoCompleteSettings(props: IProps): React.JSX.Element { const [settings, _setSettings] = useState(props.settings); const errors = checkForErrors(settings); React.useEffect(() => { _setSettings(props.settings); }, [props.settings]); const updateSettings = (update: Partial) => { _setSettings((settings: InfioSettings) => { const newSettings = { ...settings, ...update }; props.onSettingsChanged(newSettings); return newSettings; }); }; const resetSettings = () => { // const azureOAIApiSettings = settings.azureOAIApiSettings, // const openAIApiSettings = settings.openAIApiSettings, // const ollamaApiSettings = settings.ollamaApiSettings // const newSettings: SmartCopilotSettings = { // ...settings // azureOAIApiSettings, // openAIApiSettings, // ollamaApiSettings, // advancedMode: settings.advancedMode, // }; // updateSettings(newSettings); new Notice("Factory reset complete."); }; // const renderAPISettings = () => { // if (settings.apiProvider === "azure") { // return ( // <> // // updateSettings({ // azureOAIApiSettings: { // ...settings.azureOAIApiSettings, // url: value, // }, // }) // } // /> // // updateSettings({ // azureOAIApiSettings: { // ...settings.azureOAIApiSettings, // key: value, // }, // }) // } // /> // // // ); // } // if (settings.apiProvider === "openai") { // return ( // <> // // updateSettings({ // openAIApiSettings: { // ...settings.openAIApiSettings, // url: value, // }, // }) // } // /> // // updateSettings({ // openAIApiSettings: { // ...settings.openAIApiSettings, // key: value, // }, // }) // } // /> // // updateSettings({ // openAIApiSettings: { // ...settings.openAIApiSettings, // model: value, // } // }) // } // errorMessage={errors.get("openAIApiSettings.model")} // /> // // // ); // } // if (settings.apiProvider === "ollama") { // return ( // <> // // updateSettings({ // ollamaApiSettings: { // ...settings.ollamaApiSettings, // url: value, // }, // }) // } // /> // // updateSettings({ // ollamaApiSettings: { // ...settings.ollamaApiSettings, // model: value, // } // }) // } // errorMessage={errors.get("ollamaApiSettings.model")} // /> // // // ); // } // }; return (

AutoComplete

updateSettings({ autocompleteEnabled: value })} /> updateSettings({ cacheSuggestions: value })} /> {/* { if (value === "openai" || value === "azure" || value === "ollama") { updateSettings({ apiProvider: value }); } }} options={{ openai: "OpenAI API", azure: "Azure OAI API", ollama: "Self-hosted OLLAMA API" }} errorMessage={errors.get("apiProvider")} /> */} updateSettings({ debugMode: value })} /> {/*

API

{renderAPISettings()} */}

Model Options

updateSettings({ modelOptions: { ...settings.modelOptions, temperature: value, }, }) } min={MIN_TEMPERATURE} max={MAX_TEMPERATURE} step={0.05} /> updateSettings({ modelOptions: { ...settings.modelOptions, top_p: value, }, }) } min={MIN_TOP_P} max={MAX_TOP_P} step={0.05} /> {settings.apiProvider !== "ollama" && (<> updateSettings({ modelOptions: { ...settings.modelOptions, frequency_penalty: value, }, }) } min={MIN_FREQUENCY_PENALTY} max={MAX_FREQUENCY_PENALTY} step={0.05} /> updateSettings({ modelOptions: { ...settings.modelOptions, presence_penalty: value, }, }) } min={MIN_PRESENCE_PENALTY} max={MAX_PRESENCE_PENALTY} step={0.05} /> updateSettings({ modelOptions: { ...settings.modelOptions, max_tokens: value, }, }) } min={MIN_MAX_TOKENS} max={MAX_MAX_TOKENS} step={10} /> )}

Preprocessing

updateSettings({ dontIncludeDataviews: value }) } /> updateSettings({ maxPrefixCharLimit: value }) } min={MIN_MAX_CHAR_LIMIT} max={MAX_MAX_CHAR_LIMIT} step={100} suffix={" chars"} /> updateSettings({ maxSuffixCharLimit: value }) } min={MIN_MAX_CHAR_LIMIT} max={MAX_MAX_CHAR_LIMIT} step={100} suffix={" chars"} />

Postprocessing

updateSettings({ removeDuplicateMathBlockIndicator: value }) } /> updateSettings({ removeDuplicateCodeBlockIndicator: value }) } />

Trigger

updateSettings({ delay: value })} min={MIN_DELAY} max={MAX_DELAY} step={100} suffix={"ms"} /> updateSettings({ triggers })} errorMessage={errors.get("triggerWords")} errorMessages={errors} />

Privacy

This field enables you to specify files and directories that the plugin should ignore. When you open any of these files, the plugin will automatically disable itself and display a 'disabled' status in the bottom menu. Enter one pattern per line. These patterns function similar to glob patterns. Here are some frequently used patterns:

  • path/to/folder/**: This pattern ignores all files and sub folders within this folder.
  • "**/secret/**": This pattern ignores any file located inside a 'secret' directory, regardless of its location in the path.
  • !path/to/folder/example.md: This pattern explicitly undoes an ignore, making this file noticeable to the plugin.
  • **/*Python*.md: This pattern ignores any file with 'Python' in its name, irrespective of its location.
} display={"block"} errorMessage={errors.get("ignoredFilePatterns")} >