-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from your-papa/dev
Release 0.6.0
- Loading branch information
Showing
15 changed files
with
317 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import { isOllamaRunning } from '../../controller/Ollama'; | ||
import PullOllamaModel from '../Onboarding/PullOllamaModel.svelte'; | ||
import SettingContainer from '../Settings/SettingContainer.svelte'; | ||
import { t } from 'svelte-i18n'; | ||
import { data } from '../../store'; | ||
import { OllamaGenModelNames, OllamaEmbedModelNames } from '../Settings/models'; | ||
import { getOllamaModels, ollamaGenChange, ollamaEmbedChange } from '../../controller/Ollama'; | ||
import type { PullModal } from './PullModal'; | ||
import DotAnimation from '../base/DotAnimation.svelte'; | ||
export let modal: PullModal; | ||
let model = ''; | ||
let isOllama: boolean; | ||
let pulledModel = false; | ||
let installedOllamaModels: string[] = []; | ||
onMount(async () => { | ||
installedOllamaModels = await getOllamaModels(); | ||
isOllama = await isOllamaRunning(); | ||
}); | ||
</script> | ||
|
||
<div class="modal-title">{$t('cmd.pull_model')}</div> | ||
<div class="modal-content"> | ||
{#if !isOllama} | ||
Ollama is Not Running | ||
{:else if isOllama === undefined} | ||
Loading | ||
<DotAnimation /> | ||
{:else} | ||
<PullOllamaModel | ||
text={$t('modal.pull_model_name')} | ||
desc={$t('modal.pull_model_desc')} | ||
onSuccessfulPull={async () => { | ||
installedOllamaModels = await getOllamaModels(); | ||
pulledModel = true; | ||
}} | ||
/> | ||
{#if pulledModel} | ||
<SettingContainer | ||
name={$t('settings.ollama.gen_model')} | ||
desc={$t('settings.ollama.model_descriptions.' + $data.ollamaGenModel.model, { default: '' })} | ||
> | ||
<select class="dropdown" bind:value={$data.ollamaGenModel.model} on:change={() => ollamaGenChange($data.ollamaGenModel.model)}> | ||
<optgroup label={$t('settings.ollama.recommended')}> | ||
{#each OllamaGenModelNames as model} | ||
<option value={model}>{model}</option> | ||
{/each} | ||
</optgroup> | ||
<optgroup label={$t('settings.ollama.other')}> | ||
{#each installedOllamaModels.filter((model) => !OllamaGenModelNames.includes(model) && !OllamaEmbedModelNames.includes(model)) as model} | ||
<option value={model}>{model}</option> | ||
{/each} | ||
</optgroup> | ||
</select> | ||
</SettingContainer> | ||
<!-- Ollama Embed Model --> | ||
<SettingContainer | ||
name={$t('settings.ollama.embed_model')} | ||
desc={$t('settings.ollama.model_descriptions.' + $data.ollamaEmbedModel.model, { default: '' })} | ||
> | ||
<select class="dropdown" bind:value={$data.ollamaEmbedModel.model} on:change={() => ollamaEmbedChange($data.ollamaEmbedModel.model)}> | ||
<optgroup label={$t('settings.ollama.recommended')}> | ||
{#each OllamaEmbedModelNames as model} | ||
<option value={model}>{model}</option> | ||
{/each} | ||
</optgroup> | ||
<optgroup label={$t('settings.ollama.other')}> | ||
{#each installedOllamaModels.filter((model) => !OllamaEmbedModelNames.includes(model)) as model} | ||
<option value={model}>{model}</option> | ||
{/each} | ||
</optgroup> | ||
</select> | ||
</SettingContainer> | ||
{/if} | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Modal, App } from 'obsidian'; | ||
import PullComponent from './PullModal.svelte'; | ||
|
||
export class PullModal extends Modal { | ||
component: PullComponent; | ||
constructor(app: App) { | ||
super(app); | ||
} | ||
|
||
onOpen() { | ||
new PullComponent({ | ||
target: this.contentEl, | ||
props: { | ||
modal: this, | ||
}, | ||
}); | ||
} | ||
|
||
onClose() { | ||
const { contentEl } = this; | ||
contentEl.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import { deleteOllamaModels, isOllamaRunning } from '../../controller/Ollama'; | ||
import { t } from 'svelte-i18n'; | ||
import { getOllamaModels } from '../../controller/Ollama'; | ||
import type { PullModal } from './PullModal'; | ||
import DropdownComponent from '../base/Dropdown.svelte'; | ||
import DotAnimation from '../base/DotAnimation.svelte'; | ||
export let modal: PullModal; | ||
let model = ''; | ||
let isOllama: boolean; | ||
let installedOllamaModels: string[] = []; | ||
onMount(async () => { | ||
installedOllamaModels = await getOllamaModels(); | ||
isOllama = await isOllamaRunning(); | ||
}); | ||
</script> | ||
|
||
<div class="modal-title">{$t('cmd.remove_model')}</div> | ||
<div class="modal-content"> | ||
{#if isOllama === false} | ||
Ollama is Not Running | ||
{:else if isOllama === undefined} | ||
Loading | ||
<DotAnimation /> | ||
{:else} | ||
<div class="mb-1 flex items-center justify-between"> | ||
<div> | ||
<div class="setting-item-name">{$t('modal.remove.name')}</div> | ||
<div class="setting-item-description">{$t('modal.remove.desc')}</div> | ||
</div> | ||
<div class="flex flex-row justify-end gap-2"> | ||
<DropdownComponent | ||
options={installedOllamaModels.map((model) => ({ display: model, value: model }))} | ||
selected={model} | ||
changeFunc={(e) => (model = e)} | ||
/> | ||
<button | ||
class="mod-warning" | ||
on:click={async () => { | ||
await deleteOllamaModels(model); | ||
installedOllamaModels = await getOllamaModels(); | ||
}}>{$t('general.delete')}</button | ||
> | ||
</div> | ||
</div> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Modal, App } from 'obsidian'; | ||
import RemoveComponent from './RemoveModal.svelte'; | ||
|
||
export class RemoveModal extends Modal { | ||
component: RemoveComponent; | ||
constructor(app: App) { | ||
super(app); | ||
} | ||
|
||
onOpen() { | ||
new RemoveComponent({ | ||
target: this.contentEl, | ||
props: { | ||
modal: this, | ||
}, | ||
}); | ||
} | ||
|
||
onClose() { | ||
const { contentEl } = this; | ||
contentEl.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.