Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input #8

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import NewChat from './lib/NewChat.svelte'
import { chatsStorage, setGlobalSettingValueByKey } from './lib/Storage.svelte'
import { Modals, closeModal } from 'svelte-modals'
import { dispatchModalEsc } from './lib/Util.svelte'
import { dispatchModalEsc, checkModalEsc } from './lib/Util.svelte'
import { set as setOpenAI } from './lib/providers/openai/util.svelte'
import { hasActiveModels } from './lib/Models.svelte'

Expand Down Expand Up @@ -72,3 +72,18 @@
on:click={closeModal}
/>
</Modals>

<svelte:window
on:keydown={(e) => checkModalEsc(e)}
/>

<style>
.backdrop {
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: transparent
}
</style>
22 changes: 16 additions & 6 deletions src/lib/Home.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<script lang="ts">
import { apiKeyStorage, globalStorage, lastChatId, getChat, started, checkStateChange } from './Storage.svelte'
import { apiKeyStorage, globalStorage, lastChatId, getChat, started, setGlobalSettingValueByKey, checkStateChange } from './Storage.svelte'
import Footer from './Footer.svelte'
import { replace } from 'svelte-spa-router'
import { afterUpdate, onMount } from 'svelte'
import { getPetalsBase, getPetalsWebsocket } from './ApiUtil.svelte'
import { set as setOpenAI } from './providers/openai/util.svelte'
import { hasActiveModels } from './Models.svelte'

$: apiKey = $apiKeyStorage

let showPetalsSettings = $globalStorage.enablePetals
let pedalsEndpoint = $globalStorage.pedalsEndpoint
let hasModels = hasActiveModels()

Expand All @@ -29,10 +32,17 @@ afterUpdate(() => {
$checkStateChange++
})

const setPetalsEnabled = (event: Event) => {
const el = (event.target as HTMLInputElement)
setGlobalSettingValueByKey('enablePetals', !!el.checked)
showPetalsSettings = $globalStorage.enablePetals
hasModels = hasActiveModels()
}

</script>

<section class="section">
<!--<article class="message">
<article class="message">
<div class="message-body">
<p class="mb-4">
<strong><a href="https://github.com/Niek/chatgpt-web" target="_blank">ChatGPT-web</a></strong>
Expand Down Expand Up @@ -94,11 +104,11 @@ afterUpdate(() => {
<article class="message" class:is-danger={!hasModels} class:is-warning={!showPetalsSettings} class:is-info={showPetalsSettings}>
<div class="message-body">
<label class="label" for="enablePetals">
<input
<input
type="checkbox"
class="checkbox"
class="checkbox"
id="enablePetals"
checked={!!$globalStorage.enablePetals}
checked={!!$globalStorage.enablePetals}
on:click={setPetalsEnabled}
>
Use Petals API and Models (Llama 2)
Expand Down Expand Up @@ -153,7 +163,7 @@ afterUpdate(() => {
</p>
{/if}
</div>
</article> -->
</article>
{#if apiKey}
<article class="message is-info">
<div class="message-body">
Expand Down